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

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

d = A("d")
e = B("e")
m = A("m")
k = A("k")
g = B("g")
c = B("c")
n = A("n")
i = A("i")
b = B("b")

d.u = b
e.u = g
m.u = b
k.u = g
g.u = b
c.u = g
n.u = b
i.u = b
b.u = g
assert k.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

d = A("d")
e = B("e")
m = A("m")
k = A("k")
g = B("g")
c = B("c")
n = A("n")
i = A("i")
b = B("b")

d.u = b
e.u = g
m.u = b
k.u = g
g.u = b
c.u = g
n.u = b
i.u = b
b.u = g
assert k.u.u.u.u.u.u.txt == "b"