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

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

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

h = A("h")
e = B("e")
b = C("b")
f = C("f")
n = C("n")
a = C("a")
m = C("m")
d = C("d")

h.o = e
e.z = h
e.v = h
e.o = m
b.u = d
f.u = a
n.u = b
a.u = m
m.u = f
d.u = b
assert f.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
b = C("b")
f = C("f")
n = C("n")
a = C("a")
m = C("m")
d = C("d")

h.o = e
e.z = h
e.v = h
e.o = m
b.u = d
f.u = a
n.u = b
a.u = m
m.u = f
d.u = b
assert f.u.u.u.u.u.u.u.u.txt == "m"