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

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

b = A("b")
m = B("m")
f = A("f")
g = A("g")
k = B("k")
j = B("j")
l = A("l")
c = A("c")

b.x = j
m.t = k
f.x = j
g.x = k
k.t = m
j.t = k
l.x = k
c.x = k
assert c.x.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

b = A("b")
m = B("m")
f = A("f")
g = A("g")
k = B("k")
j = B("j")
l = A("l")
c = A("c")

b.x = j
m.t = k
f.x = j
g.x = k
k.t = m
j.t = k
l.x = k
c.x = k
assert c.x.t.t.t.t.t.t.txt == "k"