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

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

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

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

n = A("n")
m = B("m")
g = C("g")
e = D("e")
c = C("c")
d = A("d")
i = B("i")
a = A("a")

n.y = e
m.t = i
m.q = i
m.z = e
g.r = i
g.o = c
g.x = e
e.w = d
e.x = a
e.r = g
c.r = i
c.o = g
c.x = e
d.y = e
i.t = m
i.q = m
i.z = e
a.y = e
assert m.t.t.z.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

n = A("n")
m = B("m")
g = C("g")
e = D("e")
c = C("c")
d = A("d")
i = B("i")
a = A("a")

n.y = e
m.t = i
m.q = i
m.z = e
g.r = i
g.o = c
g.x = e
e.w = d
e.x = a
e.r = g
c.r = i
c.o = g
c.x = e
d.y = e
i.t = m
i.q = m
i.z = e
a.y = e
assert m.t.t.z.w.y.txt == "e"