class A:
    def __init__(self, txt: str):
        self.t: 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.v: B = None
        self.u: C = None
        self.x: B = None
        self.txt = txt

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

d.t = b
k.z = g
f.v = k
f.u = e
f.x = g
j.t = d
b.t = j
g.z = k
e.v = k
e.x = k
e.u = f
assert d.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: 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.v: B = None
        self.u: C = None
        self.x: B = None
        self.txt = txt

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

d.t = b
k.z = g
f.v = k
f.u = e
f.x = g
j.t = d
b.t = j
g.z = k
e.v = k
e.x = k
e.u = f
assert d.t.t.t.t.t.t.t.txt == "b"