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

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

e = A("e")
n = B("n")
c = A("c")
h = A("h")
a = B("a")
d = B("d")
k = A("k")
l = A("l")
j = A("j")

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

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

e = A("e")
n = B("n")
c = A("c")
h = A("h")
a = B("a")
d = B("d")
k = A("k")
l = A("l")
j = A("j")

e.q = n
n.v = l
n.z = c
c.q = d
h.q = n
a.v = e
a.z = e
d.v = c
d.z = l
k.q = a
l.q = n
j.q = a
assert k.q.v.q.v.txt == "l"