class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: D = None
        self.v: B = None
        self.txt = txt

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

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

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

h.q = n
h.u = a
h.w = g
a.y = c
a.x = c
a.z = h
g.o = n
g.u = n
g.v = a
n.s = g
c.s = a
c.t = g
assert h.w.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: D = None
        self.v: B = None
        self.txt = txt

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

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

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

h.q = n
h.u = a
h.w = g
a.y = c
a.x = c
a.z = h
g.o = n
g.u = n
g.v = a
n.s = g
c.s = a
c.t = g
assert h.w.v.z.txt == "h"