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

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

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

g.t = e
e.x = b
k.t = e
b.x = e
i.t = e
assert g.t.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

g.t = e
e.x = b
k.t = e
b.x = e
i.t = e
assert g.t.x.x.x.txt == "b"