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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: A = None
        self.y: C = None
        self.t: A = None
        self.o: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: E = None
        self.z: C = None
        self.y: C = None
        self.txt = txt

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

b = A("b")
n = B("n")
h = C("h")
g = D("g")
l = E("l")
d = D("d")

b.w = n
b.q = n
b.o = h
b.p = l
n.x = d
n.w = b
n.t = b
n.y = h
n.o = l
h.x = n
h.t = l
g.s = h
g.z = h
g.y = h
g.p = l
l.o = g
l.q = h
l.x = h
l.t = n
l.w = n
d.s = h
d.z = h
d.y = h
d.p = l
assert d.p.o.p.o.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: C = None
        self.q: B = None
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: A = None
        self.y: C = None
        self.t: A = None
        self.o: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: E = None
        self.z: C = None
        self.y: C = None
        self.txt = txt

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

b = A("b")
n = B("n")
h = C("h")
g = D("g")
l = E("l")
d = D("d")

b.w = n
b.q = n
b.o = h
b.p = l
n.x = d
n.w = b
n.t = b
n.y = h
n.o = l
h.x = n
h.t = l
g.s = h
g.z = h
g.y = h
g.p = l
l.o = g
l.q = h
l.x = h
l.t = n
l.w = n
d.s = h
d.z = h
d.y = h
d.p = l
assert d.p.o.p.o.p.w.txt == "n"