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

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

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

l.u = k
e.w = i
e.x = i
i.w = e
i.x = e
m.u = k
g.u = k
k.u = f
f.u = k
assert m.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.w: B = None
        self.x: B = None
        self.txt = txt

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

l.u = k
e.w = i
e.x = i
i.w = e
i.x = e
m.u = k
g.u = k
k.u = f
f.u = k
assert m.u.u.u.u.u.u.txt == "f"