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

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

l = A("l")
k = B("k")
c = A("c")
n = A("n")
i = B("i")
h = A("h")
a = B("a")
f = B("f")
b = B("b")
g = B("g")

l.u = h
k.t = c
c.u = h
n.u = h
i.t = n
h.u = c
a.t = n
f.t = l
b.t = c
g.t = c
assert a.t.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.t: A = None
        self.txt = txt

l = A("l")
k = B("k")
c = A("c")
n = A("n")
i = B("i")
h = A("h")
a = B("a")
f = B("f")
b = B("b")
g = B("g")

l.u = h
k.t = c
c.u = h
n.u = h
i.t = n
h.u = c
a.t = n
f.t = l
b.t = c
g.t = c
assert a.t.u.u.txt == "c"