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

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

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

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

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

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

d.v = g
d.p = l
k.u = g
n.u = h
m.u = h
e.v = b
e.p = d
a.v = n
a.p = l
g.u = h
l.v = b
l.p = a
h.u = m
b.u = k
assert k.u.u.u.u.txt == "h"