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

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

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

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

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

d.w = e
d.r = e
d.x = k
d.u = f
a.o = d
a.w = k
a.z = f
a.y = m
k.r = a
k.w = f
i.p = m
i.u = k
i.s = b
b.p = i
b.s = i
b.u = k
e.w = d
e.r = d
e.x = k
e.u = f
m.p = i
m.s = i
m.u = k
f.o = e
f.w = k
f.z = a
f.y = m
assert a.w.w.w.r.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.u: B = None
        self.r: A = None
        self.txt = txt

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

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

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

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

d.w = e
d.r = e
d.x = k
d.u = f
a.o = d
a.w = k
a.z = f
a.y = m
k.r = a
k.w = f
i.p = m
i.u = k
i.s = b
b.p = i
b.s = i
b.u = k
e.w = d
e.r = d
e.x = k
e.u = f
m.p = i
m.s = i
m.u = k
f.o = e
f.w = k
f.z = a
f.y = m
assert a.w.w.w.r.z.z.txt == "a"