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

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

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

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

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

b = A("b")
i = B("i")
d = C("d")
n = D("n")
g = E("g")
k = D("k")
m = B("m")
h = A("h")
l = C("l")

b.v = l
i.w = l
i.r = b
i.v = d
d.p = n
n.z = i
g.v = m
g.z = i
g.s = h
g.r = h
g.y = d
k.z = m
m.w = l
m.r = h
m.v = d
h.v = d
l.p = k
assert m.r.v.p.z.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

b = A("b")
i = B("i")
d = C("d")
n = D("n")
g = E("g")
k = D("k")
m = B("m")
h = A("h")
l = C("l")

b.v = l
i.w = l
i.r = b
i.v = d
d.p = n
n.z = i
g.v = m
g.z = i
g.s = h
g.r = h
g.y = d
k.z = m
m.w = l
m.r = h
m.v = d
h.v = d
l.p = k
assert m.r.v.p.z.w.p.txt == "k"