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

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

n = A("n")
m = B("m")
b = A("b")
c = B("c")

n.t = b
m.v = n
b.t = n
c.v = b
assert m.v.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.v: A = None
        self.txt = txt

n = A("n")
m = B("m")
b = A("b")
c = B("c")

n.t = b
m.v = n
b.t = n
c.v = b
assert m.v.t.t.t.txt == "b"