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

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

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

i.q = f
i.v = j
k.u = n
k.p = n
c.u = e
c.p = n
f.q = l
f.v = l
e.u = k
e.p = n
n.u = c
n.p = k
j.q = l
j.v = f
d.q = j
d.v = i
l.q = d
l.v = j
h.q = j
h.v = i
assert e.p.u.u.p.p.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.txt = txt

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

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

i.q = f
i.v = j
k.u = n
k.p = n
c.u = e
c.p = n
f.q = l
f.v = l
e.u = k
e.p = n
n.u = c
n.p = k
j.q = l
j.v = f
d.q = j
d.v = i
l.q = d
l.v = j
h.q = j
h.v = i
assert e.p.u.u.p.p.p.u.txt == "c"