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

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

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

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

f = A("f")
a = B("a")
h = C("h")
k = D("k")
d = C("d")

f.p = k
f.w = k
f.x = k
f.y = k
a.w = k
a.u = f
h.z = a
h.o = a
h.x = d
k.s = h
d.z = a
d.o = a
d.x = h
assert f.p.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: D = None
        self.x: D = None
        self.y: D = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
h = C("h")
k = D("k")
d = C("d")

f.p = k
f.w = k
f.x = k
f.y = k
a.w = k
a.u = f
h.z = a
h.o = a
h.x = d
k.s = h
d.z = a
d.o = a
d.x = h
assert f.p.s.x.x.txt == "h"