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

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

m = A("m")
h = B("h")
l = A("l")
n = A("n")
j = A("j")
k = A("k")
c = A("c")

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

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

m = A("m")
h = B("h")
l = A("l")
n = A("n")
j = A("j")
k = A("k")
c = A("c")

m.v = c
m.q = c
h.v = m
h.q = k
l.v = n
l.q = j
n.v = m
n.q = k
j.v = k
j.q = c
k.v = m
k.q = m
c.v = k
c.q = n
assert k.v.q.q.q.q.q.txt == "c"