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

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

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

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

n = A("n")
j = B("j")
m = C("m")
i = D("i")
g = C("g")
b = A("b")
f = B("f")
e = D("e")

n.v = f
j.y = f
j.r = g
j.p = b
m.r = j
m.t = n
m.s = b
m.v = e
i.w = b
i.s = e
i.z = m
g.r = f
g.t = b
g.s = b
g.v = i
b.v = j
f.y = j
f.r = m
f.p = b
e.w = b
e.s = i
e.z = m
assert n.v.p.v.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
m = C("m")
i = D("i")
g = C("g")
b = A("b")
f = B("f")
e = D("e")

n.v = f
j.y = f
j.r = g
j.p = b
m.r = j
m.t = n
m.s = b
m.v = e
i.w = b
i.s = e
i.z = m
g.r = f
g.t = b
g.s = b
g.v = i
b.v = j
f.y = j
f.r = m
f.p = b
e.w = b
e.s = i
e.z = m
assert n.v.p.v.r.r.r.txt == "m"