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

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

m = A("m")
f = B("f")
e = B("e")
n = A("n")

m.t = n
f.t = m
e.t = m
n.t = m
assert m.t.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.t: A = None
        self.txt = txt

m = A("m")
f = B("f")
e = B("e")
n = A("n")

m.t = n
f.t = m
e.t = m
n.t = m
assert m.t.t.t.txt == "n"