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

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

i = A("i")
c = B("c")
k = B("k")
b = B("b")
a = B("a")
j = A("j")
m = B("m")
d = B("d")

i.u = b
c.u = j
k.u = j
b.u = j
a.u = i
j.u = b
m.u = i
d.u = j
assert b.u.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: A = None
        self.txt = txt

i = A("i")
c = B("c")
k = B("k")
b = B("b")
a = B("a")
j = A("j")
m = B("m")
d = B("d")

i.u = b
c.u = j
k.u = j
b.u = j
a.u = i
j.u = b
m.u = i
d.u = j
assert b.u.u.u.u.u.u.u.txt == "j"