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

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

g = A("g")
k = B("k")
a = A("a")
i = B("i")
e = A("e")

g.t = e
k.s = i
a.t = g
i.s = k
e.t = a
assert e.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.s: B = None
        self.txt = txt

g = A("g")
k = B("k")
a = A("a")
i = B("i")
e = A("e")

g.t = e
k.s = i
a.t = g
i.s = k
e.t = a
assert e.t.t.t.t.txt == "a"