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

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

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

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

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

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

j.t = e
n.y = e
b.t = a
g.y = c
l.y = b
a.t = b
h.y = c
m.t = j
e.t = m
c.t = j
assert j.t.t.t.t.t.t.txt == "j"