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

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

e = A("e")
g = B("g")
j = A("j")
k = A("k")
b = A("b")
m = A("m")
l = B("l")
i = A("i")

e.u = k
g.u = l
j.u = b
k.u = b
b.u = j
m.u = k
l.u = g
i.u = b
assert g.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
j = A("j")
k = A("k")
b = A("b")
m = A("m")
l = B("l")
i = A("i")

e.u = k
g.u = l
j.u = b
k.u = b
b.u = j
m.u = k
l.u = g
i.u = b
assert g.u.u.u.u.u.u.u.u.txt == "g"