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

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

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

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

g = A("g")
h = B("h")
c = C("c")
n = D("n")
f = D("f")
b = B("b")
i = A("i")
d = C("d")
a = D("a")
k = A("k")

g.q = b
g.s = h
g.w = c
h.w = d
c.p = h
c.t = h
c.r = k
c.q = d
n.z = f
n.s = d
n.t = a
f.z = a
f.s = d
f.t = n
b.w = c
i.q = h
i.s = h
i.w = c
d.p = b
d.t = h
d.r = i
d.q = c
a.z = f
a.s = d
a.t = n
k.q = h
k.s = h
k.w = c
assert f.s.p.w.q.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: B = None
        self.w: C = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
c = C("c")
n = D("n")
f = D("f")
b = B("b")
i = A("i")
d = C("d")
a = D("a")
k = A("k")

g.q = b
g.s = h
g.w = c
h.w = d
c.p = h
c.t = h
c.r = k
c.q = d
n.z = f
n.s = d
n.t = a
f.z = a
f.s = d
f.t = n
b.w = c
i.q = h
i.s = h
i.w = c
d.p = b
d.t = h
d.r = i
d.q = c
a.z = f
a.s = d
a.t = n
k.q = h
k.s = h
k.w = c
assert f.s.p.w.q.t.w.txt == "d"