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

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

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

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

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

b.w = k
b.s = k
b.q = k
b.p = k
h.y = n
n.z = c
n.v = c
n.y = c
n.q = c
a.w = j
i.y = n
d.w = b
d.q = b
d.s = k
d.p = k
k.w = d
k.s = d
k.q = d
k.p = b
e.y = n
j.y = n
c.w = e
assert a.w.y.z.w.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.s: A = None
        self.q: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

b.w = k
b.s = k
b.q = k
b.p = k
h.y = n
n.z = c
n.v = c
n.y = c
n.q = c
a.w = j
i.y = n
d.w = b
d.q = b
d.s = k
d.p = k
k.w = d
k.s = d
k.q = d
k.p = b
e.y = n
j.y = n
c.w = e
assert a.w.y.z.w.y.q.txt == "c"