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.u: B = None
        self.z: B = None
        self.txt = txt

l = A("l")
d = B("d")
f = A("f")
j = B("j")
b = A("b")
m = B("m")
h = B("h")
c = A("c")

l.v = b
l.q = f
d.u = m
d.z = m
f.v = l
f.q = l
j.u = h
j.z = d
b.v = c
b.q = c
m.u = d
m.z = h
h.u = m
h.z = d
c.v = f
c.q = b
assert c.v.q.v.v.v.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.u: B = None
        self.z: B = None
        self.txt = txt

l = A("l")
d = B("d")
f = A("f")
j = B("j")
b = A("b")
m = B("m")
h = B("h")
c = A("c")

l.v = b
l.q = f
d.u = m
d.z = m
f.v = l
f.q = l
j.u = h
j.z = d
b.v = c
b.q = c
m.u = d
m.z = h
h.u = m
h.z = d
c.v = f
c.q = b
assert c.v.q.v.v.v.q.q.txt == "f"