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

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

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

b.t = e
g.w = e
g.o = e
e.t = b
assert g.o.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.w: A = None
        self.o: A = None
        self.txt = txt

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

b.t = e
g.w = e
g.o = e
e.t = b
assert g.o.t.t.txt == "e"