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

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

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

m.v = n
m.z = k
k.q = c
c.q = b
n.q = b
d.v = k
d.z = c
b.q = n
assert c.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.txt = txt

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

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

m.v = n
m.z = k
k.q = c
c.q = b
n.q = b
d.v = k
d.z = c
b.q = n
assert c.q.q.q.q.q.q.txt == "n"