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

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

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

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

n = A("n")
i = B("i")
g = C("g")
h = D("h")
k = A("k")
f = A("f")
a = D("a")
e = B("e")

n.w = e
i.r = g
i.t = g
i.s = e
g.q = e
h.w = a
h.s = a
h.q = g
h.x = g
k.w = i
f.w = e
a.w = h
a.s = h
a.q = g
a.x = g
e.r = g
e.t = g
e.s = i
assert h.s.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
g = C("g")
h = D("h")
k = A("k")
f = A("f")
a = D("a")
e = B("e")

n.w = e
i.r = g
i.t = g
i.s = e
g.q = e
h.w = a
h.s = a
h.q = g
h.x = g
k.w = i
f.w = e
a.w = h
a.s = h
a.q = g
a.x = g
e.r = g
e.t = g
e.s = i
assert h.s.q.q.txt == "e"