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

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

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

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

a = A("a")
d = B("d")
n = C("n")
k = D("k")
i = D("i")
l = B("l")
f = D("f")

a.w = d
a.p = f
a.u = n
d.r = n
d.y = a
d.s = a
d.p = k
n.r = l
n.w = a
n.o = k
k.w = n
i.w = n
l.r = n
l.y = a
l.s = a
l.p = k
f.w = n
assert d.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: D = None
        self.u: C = None
        self.txt = txt

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

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

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

a = A("a")
d = B("d")
n = C("n")
k = D("k")
i = D("i")
l = B("l")
f = D("f")

a.w = d
a.p = f
a.u = n
d.r = n
d.y = a
d.s = a
d.p = k
n.r = l
n.w = a
n.o = k
k.w = n
i.w = n
l.r = n
l.y = a
l.s = a
l.p = k
f.w = n
assert d.p.w.w.txt == "a"