class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: C = None
        self.p: E = None
        self.y: A = None
        self.txt = txt

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

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

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

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

j = A("j")
m = B("m")
a = C("a")
b = D("b")
l = E("l")
n = B("n")
d = A("d")
g = A("g")
c = D("c")

j.x = c
j.z = a
j.p = l
j.y = g
m.r = l
m.p = n
a.y = d
a.p = c
a.v = g
a.s = b
b.v = j
l.v = g
n.r = l
n.p = m
d.x = b
d.z = a
d.p = l
d.y = g
g.x = c
g.z = a
g.p = l
g.y = j
c.v = j
assert m.p.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: C = None
        self.p: E = None
        self.y: A = None
        self.txt = txt

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

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

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

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

j = A("j")
m = B("m")
a = C("a")
b = D("b")
l = E("l")
n = B("n")
d = A("d")
g = A("g")
c = D("c")

j.x = c
j.z = a
j.p = l
j.y = g
m.r = l
m.p = n
a.y = d
a.p = c
a.v = g
a.s = b
b.v = j
l.v = g
n.r = l
n.p = m
d.x = b
d.z = a
d.p = l
d.y = g
g.x = c
g.z = a
g.p = l
g.y = j
c.v = j
assert m.p.p.r.txt == "l"