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

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

k = A("k")
b = B("b")
l = A("l")
h = A("h")
f = A("f")
e = A("e")
i = A("i")
c = B("c")

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

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

k = A("k")
b = B("b")
l = A("l")
h = A("h")
f = A("f")
e = A("e")
i = A("i")
c = B("c")

k.q = c
k.u = e
b.t = c
l.q = c
l.u = k
h.q = b
h.u = i
f.q = b
f.u = k
e.q = b
e.u = l
i.q = b
i.u = l
c.t = b
assert f.q.t.t.t.t.txt == "b"