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

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

e = A("e")
n = B("n")
g = B("g")
j = B("j")
l = A("l")
i = B("i")
a = B("a")
h = A("h")

e.p = h
e.w = i
n.z = l
n.o = g
g.z = h
g.o = n
j.z = e
j.o = g
l.p = h
l.w = j
i.z = e
i.o = a
a.z = h
a.o = i
h.p = l
h.w = i
assert g.z.w.z.p.w.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: B = None
        self.txt = txt

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

e = A("e")
n = B("n")
g = B("g")
j = B("j")
l = A("l")
i = B("i")
a = B("a")
h = A("h")

e.p = h
e.w = i
n.z = l
n.o = g
g.z = h
g.o = n
j.z = e
j.o = g
l.p = h
l.w = j
i.z = e
i.o = a
a.z = h
a.o = i
h.p = l
h.w = i
assert g.z.w.z.p.w.o.o.o.txt == "a"