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

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

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

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

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

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

n.r = l
m.x = i
m.u = i
l.x = j
l.u = i
d.x = e
d.u = e
e.r = m
i.r = l
j.r = d
assert m.u.r.u.r.x.r.x.txt == "e"