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

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

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

b = A("b")
j = B("j")
d = C("d")
e = A("e")
g = B("g")
n = C("n")

b.u = e
j.z = g
d.u = e
d.t = n
d.r = j
e.u = b
g.z = j
n.u = e
n.t = d
n.r = g
assert e.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
d = C("d")
e = A("e")
g = B("g")
n = C("n")

b.u = e
j.z = g
d.u = e
d.t = n
d.r = j
e.u = b
g.z = j
n.u = e
n.t = d
n.r = g
assert e.u.u.u.txt == "b"