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

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

n = A("n")
a = B("a")
d = B("d")
b = A("b")
h = B("h")
l = A("l")
k = A("k")
m = B("m")

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

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

n = A("n")
a = B("a")
d = B("d")
b = A("b")
h = B("h")
l = A("l")
k = A("k")
m = B("m")

n.u = a
n.q = b
a.v = m
a.z = l
d.v = m
d.z = l
b.u = h
b.q = n
h.v = a
h.z = l
l.u = d
l.q = b
k.u = a
k.q = n
m.v = a
m.z = n
assert h.v.v.v.z.q.txt == "b"