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

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

f = A("f")
g = B("g")
c = B("c")
e = A("e")
b = B("b")
i = B("i")
a = B("a")
m = A("m")

f.o = e
g.u = f
g.z = f
c.u = e
c.z = m
e.o = m
b.u = f
b.z = e
i.u = e
i.z = m
a.u = m
a.z = f
m.o = e
assert e.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: A = None
        self.z: A = None
        self.txt = txt

f = A("f")
g = B("g")
c = B("c")
e = A("e")
b = B("b")
i = B("i")
a = B("a")
m = A("m")

f.o = e
g.u = f
g.z = f
c.u = e
c.z = m
e.o = m
b.u = f
b.z = e
i.u = e
i.z = m
a.u = m
a.z = f
m.o = e
assert e.o.o.o.o.o.o.o.txt == "m"