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

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

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

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

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

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

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