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

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

f = A("f")
b = B("b")
m = B("m")
d = B("d")
k = B("k")
n = B("n")
h = A("h")
g = B("g")
j = A("j")
e = A("e")

f.o = h
f.r = e
b.u = m
m.u = g
d.u = g
k.u = n
n.u = m
h.o = f
h.r = e
g.u = k
j.o = e
j.r = e
e.o = h
e.r = h
assert m.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

f = A("f")
b = B("b")
m = B("m")
d = B("d")
k = B("k")
n = B("n")
h = A("h")
g = B("g")
j = A("j")
e = A("e")

f.o = h
f.r = e
b.u = m
m.u = g
d.u = g
k.u = n
n.u = m
h.o = f
h.r = e
g.u = k
j.o = e
j.r = e
e.o = h
e.r = h
assert m.u.u.u.u.u.u.txt == "k"