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

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

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

d = A("d")
j = B("j")
f = C("f")
h = C("h")
g = A("g")
a = A("a")
m = C("m")
n = A("n")

d.o = g
j.u = m
j.z = f
f.y = j
h.y = j
g.o = d
a.o = g
m.y = j
n.o = a
assert n.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
f = C("f")
h = C("h")
g = A("g")
a = A("a")
m = C("m")
n = A("n")

d.o = g
j.u = m
j.z = f
f.y = j
h.y = j
g.o = d
a.o = g
m.y = j
n.o = a
assert n.o.o.o.o.o.o.o.txt == "d"