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

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

i = A("i")
m = B("m")
e = A("e")
c = B("c")
b = A("b")
a = B("a")
g = B("g")
n = B("n")
j = B("j")

i.u = n
m.t = i
e.u = c
c.t = e
b.u = m
a.t = b
g.t = b
n.t = e
j.t = e
assert j.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

i = A("i")
m = B("m")
e = A("e")
c = B("c")
b = A("b")
a = B("a")
g = B("g")
n = B("n")
j = B("j")

i.u = n
m.t = i
e.u = c
c.t = e
b.u = m
a.t = b
g.t = b
n.t = e
j.t = e
assert j.t.u.t.txt == "e"