class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.t: D = None
        self.s: B = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
d = C("d")
n = D("n")

f.p = n
f.x = n
f.t = n
f.s = g
g.z = f
g.s = n
g.y = d
g.o = d
d.w = n
n.r = d
assert f.t.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.t: D = None
        self.s: B = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
d = C("d")
n = D("n")

f.p = n
f.x = n
f.t = n
f.s = g
g.z = f
g.s = n
g.y = d
g.o = d
d.w = n
n.r = d
assert f.t.r.w.txt == "n"