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

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

b = A("b")
f = B("f")
h = B("h")
k = B("k")
d = A("d")
e = B("e")

b.q = d
b.v = d
f.u = d
f.o = e
h.u = b
h.o = f
k.u = b
k.o = f
d.q = b
d.v = b
e.u = b
e.o = f
assert e.o.o.o.o.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.txt = txt

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

b = A("b")
f = B("f")
h = B("h")
k = B("k")
d = A("d")
e = B("e")

b.q = d
b.v = d
f.u = d
f.o = e
h.u = b
h.o = f
k.u = b
k.o = f
d.q = b
d.v = b
e.u = b
e.o = f
assert e.o.o.o.o.o.u.txt == "d"