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

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

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

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

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

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

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