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

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

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

e = A("e")
b = B("b")
k = C("k")
j = C("j")
h = C("h")
a = C("a")
c = C("c")

e.x = b
b.u = a
k.x = b
k.p = b
k.u = e
j.x = b
j.p = b
j.u = e
h.x = b
h.p = b
h.u = e
a.x = b
a.p = b
a.u = e
c.x = b
c.p = b
c.u = e
assert e.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
k = C("k")
j = C("j")
h = C("h")
a = C("a")
c = C("c")

e.x = b
b.u = a
k.x = b
k.p = b
k.u = e
j.x = b
j.p = b
j.u = e
h.x = b
h.p = b
h.u = e
a.x = b
a.p = b
a.u = e
c.x = b
c.p = b
c.u = e
assert e.x.u.x.u.txt == "a"