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

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

b = A("b")
m = B("m")
l = A("l")
g = B("g")
n = A("n")
k = B("k")
h = A("h")

b.t = h
m.x = n
m.t = g
l.t = n
g.x = h
g.t = m
n.t = h
k.x = n
k.t = m
h.t = n
assert m.x.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.x: A = None
        self.t: B = None
        self.txt = txt

b = A("b")
m = B("m")
l = A("l")
g = B("g")
n = A("n")
k = B("k")
h = A("h")

b.t = h
m.x = n
m.t = g
l.t = n
g.x = h
g.t = m
n.t = h
k.x = n
k.t = m
h.t = n
assert m.x.t.t.t.t.txt == "n"