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

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

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

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

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

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

n.y = c
n.p = d
n.o = m
m.x = n
m.z = g
d.t = m
d.y = n
d.v = n
g.o = m
c.u = g
c.s = g
l.x = n
l.z = g
assert d.v.p.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.p: C = None
        self.o: B = None
        self.txt = txt

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

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

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

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

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

n.y = c
n.p = d
n.o = m
m.x = n
m.z = g
d.t = m
d.y = n
d.v = n
g.o = m
c.u = g
c.s = g
l.x = n
l.z = g
assert d.v.p.t.x.txt == "n"