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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.txt = txt

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

m = A("m")
j = B("j")
a = C("a")
n = D("n")
c = C("c")
i = D("i")
g = A("g")
e = C("e")
l = B("l")
k = A("k")

m.x = a
m.w = k
j.p = m
j.s = i
a.u = i
a.p = e
n.v = i
c.u = i
c.p = a
i.v = n
g.x = e
g.w = k
e.u = n
e.p = a
l.p = g
l.s = n
k.x = c
k.w = m
assert j.s.v.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.txt = txt

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

m = A("m")
j = B("j")
a = C("a")
n = D("n")
c = C("c")
i = D("i")
g = A("g")
e = C("e")
l = B("l")
k = A("k")

m.x = a
m.w = k
j.p = m
j.s = i
a.u = i
a.p = e
n.v = i
c.u = i
c.p = a
i.v = n
g.x = e
g.w = k
e.u = n
e.p = a
l.p = g
l.s = n
k.x = c
k.w = m
assert j.s.v.v.v.v.v.v.v.v.v.txt == "n"