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

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

l = A("l")
d = B("d")
e = A("e")
b = A("b")
j = B("j")
k = A("k")
n = B("n")
m = A("m")

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

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

l = A("l")
d = B("d")
e = A("e")
b = A("b")
j = B("j")
k = A("k")
n = B("n")
m = A("m")

l.r = j
l.p = k
d.u = n
e.r = n
e.p = b
b.r = d
b.p = l
j.u = n
k.r = n
k.p = b
n.u = d
m.r = j
m.p = l
assert e.p.p.r.u.u.u.u.txt == "d"