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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
k = C("k")
h = D("h")
c = E("c")

i.q = n
i.z = n
i.w = n
i.o = c
n.x = c
n.p = h
k.x = n
k.r = n
k.s = i
h.r = c
h.u = i
c.o = n
c.q = k
assert h.u.w.p.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: B = None
        self.w: B = None
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
k = C("k")
h = D("h")
c = E("c")

i.q = n
i.z = n
i.w = n
i.o = c
n.x = c
n.p = h
k.x = n
k.r = n
k.s = i
h.r = c
h.u = i
c.o = n
c.q = k
assert h.u.w.p.u.o.txt == "c"