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

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

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

h = A("h")
e = B("e")
d = C("d")
i = A("i")
g = C("g")
c = C("c")
j = C("j")
a = B("a")
f = C("f")

h.t = i
e.w = h
d.z = j
i.t = h
g.z = f
c.z = d
j.z = d
a.w = i
f.z = g
assert f.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
d = C("d")
i = A("i")
g = C("g")
c = C("c")
j = C("j")
a = B("a")
f = C("f")

h.t = i
e.w = h
d.z = j
i.t = h
g.z = f
c.z = d
j.z = d
a.w = i
f.z = g
assert f.z.z.z.z.z.z.txt == "f"