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

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

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

n = A("n")
k = B("k")
f = C("f")
l = A("l")
i = C("i")
d = A("d")
j = B("j")
a = A("a")

n.v = l
k.r = n
k.x = d
f.z = k
f.u = k
f.v = i
l.v = a
i.z = k
i.v = f
i.u = j
d.v = l
j.r = d
j.x = n
a.v = l
assert i.u.r.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
f = C("f")
l = A("l")
i = C("i")
d = A("d")
j = B("j")
a = A("a")

n.v = l
k.r = n
k.x = d
f.z = k
f.u = k
f.v = i
l.v = a
i.z = k
i.v = f
i.u = j
d.v = l
j.r = d
j.x = n
a.v = l
assert i.u.r.v.v.txt == "a"