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

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

e = A("e")
b = B("b")
k = A("k")
d = A("d")
h = A("h")
a = A("a")
l = A("l")
f = B("f")
c = A("c")
m = B("m")

e.u = f
b.q = k
k.u = f
d.u = m
h.u = m
a.u = m
l.u = m
f.q = c
c.u = f
m.q = e
assert l.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

e = A("e")
b = B("b")
k = A("k")
d = A("d")
h = A("h")
a = A("a")
l = A("l")
f = B("f")
c = A("c")
m = B("m")

e.u = f
b.q = k
k.u = f
d.u = m
h.u = m
a.u = m
l.u = m
f.q = c
c.u = f
m.q = e
assert l.u.q.u.txt == "f"