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

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

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

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

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

h.s = i
h.w = i
h.q = c
c.y = i
c.q = j
c.p = b
b.w = j
b.t = m
b.y = m
b.s = n
n.x = i
a.w = j
a.t = m
a.y = m
a.s = n
m.y = i
m.q = j
m.p = a
i.s = h
i.w = h
i.q = m
j.w = b
j.t = c
j.y = c
j.s = n
assert i.q.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.q: B = None
        self.txt = txt

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

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

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

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

h.s = i
h.w = i
h.q = c
c.y = i
c.q = j
c.p = b
b.w = j
b.t = m
b.y = m
b.s = n
n.x = i
a.w = j
a.t = m
a.y = m
a.s = n
m.y = i
m.q = j
m.p = a
i.s = h
i.w = h
i.q = m
j.w = b
j.t = c
j.y = c
j.s = n
assert i.q.p.t.p.txt == "a"