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

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

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

f = A("f")
e = B("e")
i = C("i")
k = C("k")
d = C("d")
c = C("c")
b = B("b")
m = A("m")
j = A("j")

f.o = j
f.q = i
f.p = e
e.y = b
i.v = b
i.z = f
k.v = b
k.z = j
d.v = e
d.z = f
c.v = b
c.z = f
b.y = e
m.o = j
m.q = d
m.p = e
j.o = m
j.q = d
j.p = b
assert i.z.o.p.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
i = C("i")
k = C("k")
d = C("d")
c = C("c")
b = B("b")
m = A("m")
j = A("j")

f.o = j
f.q = i
f.p = e
e.y = b
i.v = b
i.z = f
k.v = b
k.z = j
d.v = e
d.z = f
c.v = b
c.z = f
b.y = e
m.o = j
m.q = d
m.p = e
j.o = m
j.q = d
j.p = b
assert i.z.o.p.y.y.y.y.y.y.txt == "b"