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

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

m = A("m")
c = B("c")
l = A("l")
h = B("h")

m.v = l
m.q = c
c.q = l
l.v = m
l.q = c
h.q = m
assert c.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

m = A("m")
c = B("c")
l = A("l")
h = B("h")

m.v = l
m.q = c
c.q = l
l.v = m
l.q = c
h.q = m
assert c.q.q.q.txt == "l"