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

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

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

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

g = A("g")
c = B("c")
j = C("j")
m = D("m")
k = D("k")
b = D("b")
a = B("a")
i = A("i")
n = C("n")

g.s = b
c.s = a
c.q = m
j.v = i
j.x = n
j.y = n
j.w = g
m.q = j
m.r = n
m.x = n
m.p = n
k.q = n
k.r = n
k.x = j
k.p = j
b.q = j
b.r = n
b.x = n
b.p = n
a.s = c
a.q = m
i.s = b
n.v = g
n.x = j
n.y = j
n.w = i
assert i.s.q.x.w.s.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
j = C("j")
m = D("m")
k = D("k")
b = D("b")
a = B("a")
i = A("i")
n = C("n")

g.s = b
c.s = a
c.q = m
j.v = i
j.x = n
j.y = n
j.w = g
m.q = j
m.r = n
m.x = n
m.p = n
k.q = n
k.r = n
k.x = j
k.p = j
b.q = j
b.r = n
b.x = n
b.p = n
a.s = c
a.q = m
i.s = b
n.v = g
n.x = j
n.y = j
n.w = i
assert i.s.q.x.w.s.q.x.txt == "n"