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

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

k = A("k")
f = B("f")
l = A("l")
m = A("m")
g = A("g")
e = A("e")
n = A("n")
j = A("j")
i = A("i")

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

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

k = A("k")
f = B("f")
l = A("l")
m = A("m")
g = A("g")
e = A("e")
n = A("n")
j = A("j")
i = A("i")

k.r = f
k.u = f
f.p = j
l.r = f
l.u = f
m.r = f
m.u = f
g.r = f
g.u = f
e.r = f
e.u = f
n.r = f
n.u = f
j.r = f
j.u = f
i.r = f
i.u = f
assert j.r.p.u.p.txt == "j"