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.r: A = None
        self.txt = txt

m = A("m")
b = B("b")
l = A("l")
f = B("f")
j = B("j")
a = B("a")
k = A("k")
h = B("h")

m.p = k
m.u = h
b.r = k
l.p = k
l.u = b
f.r = l
j.r = k
a.r = m
k.p = m
k.u = f
h.r = l
assert j.r.p.u.r.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.r: A = None
        self.txt = txt

m = A("m")
b = B("b")
l = A("l")
f = B("f")
j = B("j")
a = B("a")
k = A("k")
h = B("h")

m.p = k
m.u = h
b.r = k
l.p = k
l.u = b
f.r = l
j.r = k
a.r = m
k.p = m
k.u = f
h.r = l
assert j.r.p.u.r.txt == "l"