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

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

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

e.u = i
m.x = c
d.x = c
c.x = m
k.u = i
i.u = e
assert k.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.x: B = None
        self.txt = txt

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

e.u = i
m.x = c
d.x = c
c.x = m
k.u = i
i.u = e
assert k.u.u.u.u.u.u.txt == "e"