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

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

d = A("d")
g = B("g")
l = B("l")
m = A("m")
j = A("j")
f = B("f")
c = B("c")

d.u = m
d.o = g
g.z = f
l.z = c
m.u = j
m.o = f
j.u = m
j.o = g
f.z = c
c.z = g
assert g.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.txt = txt

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

d = A("d")
g = B("g")
l = B("l")
m = A("m")
j = A("j")
f = B("f")
c = B("c")

d.u = m
d.o = g
g.z = f
l.z = c
m.u = j
m.o = f
j.u = m
j.o = g
f.z = c
c.z = g
assert g.z.z.z.z.z.z.z.txt == "f"