class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

j = A("j")
h = B("h")
i = C("i")
a = B("a")

j.u = a
j.t = a
h.y = i
i.p = j
a.y = i
assert i.p.t.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

j = A("j")
h = B("h")
i = C("i")
a = B("a")

j.u = a
j.t = a
h.y = i
i.p = j
a.y = i
assert i.p.t.y.p.txt == "j"