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

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

k = A("k")
l = B("l")
i = A("i")
n = B("n")
e = B("e")
m = B("m")
j = B("j")
c = B("c")

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

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

k = A("k")
l = B("l")
i = A("i")
n = B("n")
e = B("e")
m = B("m")
j = B("j")
c = B("c")

k.y = i
l.t = e
i.y = k
n.t = l
e.t = l
m.t = n
j.t = e
c.t = j
assert c.t.t.t.t.t.txt == "l"