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

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

k = A("k")
g = B("g")
b = B("b")
a = B("a")
n = A("n")
e = A("e")
l = B("l")

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

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

k = A("k")
g = B("g")
b = B("b")
a = B("a")
n = A("n")
e = A("e")
l = B("l")

k.t = l
g.y = l
b.y = a
a.y = b
n.t = l
e.t = b
l.y = g
assert a.y.y.y.y.y.y.y.txt == "b"