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

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

c = A("c")
i = B("i")
e = A("e")
m = B("m")

c.t = e
i.q = c
e.t = c
m.q = c
assert i.q.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.q: A = None
        self.txt = txt

c = A("c")
i = B("i")
e = A("e")
m = B("m")

c.t = e
i.q = c
e.t = c
m.q = c
assert i.q.t.t.txt == "c"