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

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

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

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

m = A("m")
g = B("g")
i = C("i")
d = D("d")
a = D("a")
k = D("k")
f = C("f")

m.w = a
m.y = g
g.z = a
g.o = f
i.p = d
i.v = g
i.s = f
d.w = m
d.u = i
d.q = k
a.w = m
a.u = i
a.q = k
k.w = m
k.u = i
k.q = d
f.p = a
f.v = g
f.s = i
assert i.p.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
i = C("i")
d = D("d")
a = D("a")
k = D("k")
f = C("f")

m.w = a
m.y = g
g.z = a
g.o = f
i.p = d
i.v = g
i.s = f
d.w = m
d.u = i
d.q = k
a.w = m
a.u = i
a.q = k
k.w = m
k.u = i
k.q = d
f.p = a
f.v = g
f.s = i
assert i.p.w.w.q.txt == "k"