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

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

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

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

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

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

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

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

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

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

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

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

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