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

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

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

class D:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: A = None
        self.r: C = None
        self.s: D = None
        self.txt = txt

n = A("n")
e = B("e")
c = C("c")
a = D("a")
b = C("b")
m = A("m")
i = D("i")

n.u = m
n.p = e
e.o = i
e.r = m
e.v = b
c.r = m
a.t = i
a.s = i
a.u = m
a.r = b
b.r = n
m.u = n
m.p = e
i.t = a
i.s = a
i.u = n
i.r = c
assert i.r.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: A = None
        self.r: C = None
        self.s: D = None
        self.txt = txt

n = A("n")
e = B("e")
c = C("c")
a = D("a")
b = C("b")
m = A("m")
i = D("i")

n.u = m
n.p = e
e.o = i
e.r = m
e.v = b
c.r = m
a.t = i
a.s = i
a.u = m
a.r = b
b.r = n
m.u = n
m.p = e
i.t = a
i.s = a
i.u = n
i.r = c
assert i.r.r.u.txt == "n"