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

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

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.x: A = None
        self.w: B = None
        self.r: C = None
        self.txt = txt

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

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

n.z = g
n.p = i
n.v = i
n.u = d
g.t = b
i.q = n
i.v = g
i.p = b
b.p = d
b.x = n
b.w = g
b.r = i
d.x = b
l.t = b
m.q = n
m.v = l
m.p = b
assert n.z.t.r.p.r.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: C = None
        self.v: C = None
        self.u: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.x: A = None
        self.w: B = None
        self.r: C = None
        self.txt = txt

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

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

n.z = g
n.p = i
n.v = i
n.u = d
g.t = b
i.q = n
i.v = g
i.p = b
b.p = d
b.x = n
b.w = g
b.r = i
d.x = b
l.t = b
m.q = n
m.v = l
m.p = b
assert n.z.t.r.p.r.v.t.txt == "b"