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

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

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

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

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

d.s = n
f.y = j
f.q = d
f.z = d
f.s = g
b.z = f
b.x = g
b.t = g
b.w = n
n.t = f
n.x = f
n.s = b
g.z = f
g.x = b
g.t = b
g.w = j
j.t = f
j.x = f
j.s = g
assert f.q.s.s.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

d.s = n
f.y = j
f.q = d
f.z = d
f.s = g
b.z = f
b.x = g
b.t = g
b.w = n
n.t = f
n.x = f
n.s = b
g.z = f
g.x = b
g.t = b
g.w = j
j.t = f
j.x = f
j.s = g
assert f.q.s.s.x.w.txt == "j"