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

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

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

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

g = A("g")
n = B("n")
m = C("m")
i = D("i")
j = C("j")
c = A("c")
l = D("l")
k = A("k")
d = C("d")

g.x = j
g.y = c
g.w = i
n.z = l
m.w = j
m.q = i
i.x = m
i.w = n
i.s = l
j.w = d
j.q = l
c.x = m
c.y = k
c.w = l
l.x = m
l.w = n
l.s = i
k.x = d
k.y = g
k.w = i
d.w = m
d.q = i
assert d.w.q.s.x.w.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: A = None
        self.w: D = None
        self.txt = txt

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

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

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

g = A("g")
n = B("n")
m = C("m")
i = D("i")
j = C("j")
c = A("c")
l = D("l")
k = A("k")
d = C("d")

g.x = j
g.y = c
g.w = i
n.z = l
m.w = j
m.q = i
i.x = m
i.w = n
i.s = l
j.w = d
j.q = l
c.x = m
c.y = k
c.w = l
l.x = m
l.w = n
l.s = i
k.x = d
k.y = g
k.w = i
d.w = m
d.q = i
assert d.w.q.s.x.w.q.x.q.txt == "i"