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

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

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

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

n = A("n")
c = B("c")
k = C("k")
i = D("i")
a = A("a")
l = A("l")
g = A("g")
e = C("e")
d = C("d")

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

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

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

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

n = A("n")
c = B("c")
k = C("k")
i = D("i")
a = A("a")
l = A("l")
g = A("g")
e = C("e")
d = C("d")

n.q = a
n.s = k
n.w = c
n.t = l
c.r = a
c.s = i
c.z = k
k.q = n
k.r = i
i.y = n
a.q = g
a.s = d
a.w = c
a.t = n
l.q = g
l.s = d
l.w = c
l.t = a
g.q = l
g.s = d
g.w = c
g.t = n
e.q = n
e.r = i
d.q = l
d.r = i
assert c.r.w.s.y.w.z.r.txt == "i"