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

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

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

n.v = c
n.t = m
m.y = c
c.v = n
c.t = m
assert c.v.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

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