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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
a = C("a")
k = D("k")
j = E("j")
h = C("h")
d = C("d")

g.q = b
g.p = b
g.r = h
g.w = h
g.s = k
b.s = a
b.z = g
b.w = j
a.z = j
a.x = b
a.y = k
a.q = g
k.y = g
j.s = k
h.z = j
h.x = b
h.y = k
h.q = g
d.z = j
d.x = b
d.y = k
d.q = g
assert h.x.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: B = None
        self.r: C = None
        self.w: C = None
        self.s: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
a = C("a")
k = D("k")
j = E("j")
h = C("h")
d = C("d")

g.q = b
g.p = b
g.r = h
g.w = h
g.s = k
b.s = a
b.z = g
b.w = j
a.z = j
a.x = b
a.y = k
a.q = g
k.y = g
j.s = k
h.z = j
h.x = b
h.y = k
h.q = g
d.z = j
d.x = b
d.y = k
d.q = g
assert h.x.w.s.y.txt == "g"