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

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

e = A("e")
c = B("c")
g = A("g")

e.t = c
c.u = g
g.t = c
assert g.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

e = A("e")
c = B("c")
g = A("g")

e.t = c
c.u = g
g.t = c
assert g.t.u.t.txt == "c"