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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: A = None
        self.t: E = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: A = None
        self.t: E = None
        self.txt = txt

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

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

e.z = n
e.t = g
e.x = g
e.w = i
e.p = a
g.x = a
h.r = a
n.x = a
n.t = a
n.s = e
a.r = n
i.z = n
i.t = g
i.x = g
i.w = e
i.p = a
assert g.x.r.s.txt == "e"