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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: C = None
        self.s: C = None
        self.z: A = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: C = None
        self.s: C = None
        self.z: A = None
        self.txt = txt

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

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

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

f.w = i
f.u = i
f.r = n
f.t = l
n.p = f
n.z = f
n.q = h
n.s = l
h.t = f
h.y = d
i.p = n
i.z = f
i.t = d
i.w = l
l.t = f
l.y = n
d.p = f
d.z = f
d.q = h
d.s = h
assert h.t.r.p.w.p.txt == "n"