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

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

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

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

e = A("e")
j = B("j")
c = C("c")
i = D("i")
g = B("g")
m = D("m")

e.v = j
e.r = c
e.s = i
e.z = g
j.p = e
j.v = g
c.p = e
c.r = m
c.t = m
c.s = g
i.v = c
i.z = m
g.p = e
g.v = j
m.v = c
m.z = i
assert i.v.s.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: C = None
        self.s: D = None
        self.z: B = None
        self.txt = txt

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

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

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

e = A("e")
j = B("j")
c = C("c")
i = D("i")
g = B("g")
m = D("m")

e.v = j
e.r = c
e.s = i
e.z = g
j.p = e
j.v = g
c.p = e
c.r = m
c.t = m
c.s = g
i.v = c
i.z = m
g.p = e
g.v = j
m.v = c
m.z = i
assert i.v.s.v.v.p.txt == "e"