class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: D = None
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

n.t = i
n.y = i
n.o = i
h.z = g
h.r = g
h.o = e
h.q = i
e.x = n
i.q = n
i.s = n
i.r = n
i.y = h
i.w = h
g.t = h
g.z = i
assert n.o.q.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: D = None
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

n.t = i
n.y = i
n.o = i
h.z = g
h.r = g
h.o = e
h.q = i
e.x = n
i.q = n
i.s = n
i.r = n
i.y = h
i.w = h
g.t = h
g.z = i
assert n.o.q.y.w.txt == "h"