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

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

i = A("i")
c = B("c")
l = B("l")
g = A("g")

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

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

i = A("i")
c = B("c")
l = B("l")
g = A("g")

i.t = l
c.t = i
c.o = g
l.t = i
l.o = i
g.t = c
assert c.o.t.o.t.txt == "c"