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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.s: C = None
        self.o: D = None
        self.r: D = None
        self.txt = txt

k = A("k")
g = B("g")
j = C("j")
i = D("i")
h = E("h")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.s: C = None
        self.o: D = None
        self.r: D = None
        self.txt = txt

k = A("k")
g = B("g")
j = C("j")
i = D("i")
h = E("h")

k.z = g
g.o = j
g.w = j
g.p = h
g.y = h
g.z = k
j.q = h
j.z = i
j.w = i
j.y = g
i.o = h
i.x = h
i.r = g
i.t = k
i.p = k
h.t = j
h.s = j
h.z = k
h.o = i
h.r = i
assert h.s.q.s.txt == "j"