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

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

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

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

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

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

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

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

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

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

j.p = h
i.x = j
i.w = e
i.y = n
i.s = a
f.q = e
f.o = i
f.x = h
e.q = h
k.x = j
k.s = j
k.w = c
k.y = n
c.q = f
b.x = j
b.s = j
b.w = c
b.y = i
h.q = e
h.o = k
h.x = f
a.p = h
n.x = a
n.s = a
n.w = c
n.y = k
assert j.p.o.y.w.q.o.s.p.x.q.txt == "e"