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

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

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

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

k = A("k")
f = B("f")
b = C("b")
j = D("j")
m = D("m")
i = B("i")
d = D("d")

k.s = m
f.y = b
f.u = k
f.s = k
f.w = j
b.v = k
b.q = f
j.q = b
j.t = i
j.v = d
j.w = k
m.q = b
m.t = i
m.v = d
m.w = k
i.y = b
i.u = k
i.s = k
i.w = d
d.q = b
d.t = f
d.v = j
d.w = k
assert f.w.v.v.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
b = C("b")
j = D("j")
m = D("m")
i = B("i")
d = D("d")

k.s = m
f.y = b
f.u = k
f.s = k
f.w = j
b.v = k
b.q = f
j.q = b
j.t = i
j.v = d
j.w = k
m.q = b
m.t = i
m.v = d
m.w = k
i.y = b
i.u = k
i.s = k
i.w = d
d.q = b
d.t = f
d.v = j
d.w = k
assert f.w.v.v.w.s.txt == "m"