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

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

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

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

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

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

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

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

n.w = i
n.r = e
h.o = e
h.s = e
h.y = g
l.p = n
l.s = n
l.z = e
e.o = h
e.s = h
e.y = l
g.p = n
g.s = n
g.z = e
i.o = e
i.y = l
i.s = h
assert l.z.o.y.txt == "g"