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

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

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

h = A("h")
e = B("e")
b = C("b")
a = B("a")
d = A("d")

h.u = b
h.p = a
h.t = d
e.x = a
b.o = h
b.p = e
a.x = e
d.u = b
d.p = a
d.t = h
assert b.p.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: B = None
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
b = C("b")
a = B("a")
d = A("d")

h.u = b
h.p = a
h.t = d
e.x = a
b.o = h
b.p = e
a.x = e
d.u = b
d.p = a
d.t = h
assert b.p.x.x.txt == "e"