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

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

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

m = A("m")
i = B("i")
f = C("f")
b = C("b")
n = A("n")
g = C("g")
h = A("h")
k = C("k")
j = C("j")

m.x = h
i.t = b
f.z = i
b.z = i
n.x = m
g.z = i
h.x = m
k.z = i
j.z = i
assert g.z.t.z.t.z.t.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
f = C("f")
b = C("b")
n = A("n")
g = C("g")
h = A("h")
k = C("k")
j = C("j")

m.x = h
i.t = b
f.z = i
b.z = i
n.x = m
g.z = i
h.x = m
k.z = i
j.z = i
assert g.z.t.z.t.z.t.z.t.z.txt == "i"