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

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

l = A("l")
g = B("g")
k = A("k")
a = B("a")
d = A("d")
j = B("j")
b = B("b")
i = A("i")
h = A("h")

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

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

l = A("l")
g = B("g")
k = A("k")
a = B("a")
d = A("d")
j = B("j")
b = B("b")
i = A("i")
h = A("h")

l.p = i
l.u = g
g.v = h
k.p = l
k.u = g
a.v = h
d.p = i
d.u = g
j.v = l
b.v = d
i.p = k
i.u = b
h.p = l
h.u = g
assert a.v.u.v.txt == "h"