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

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

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

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

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

n = A("n")
k = B("k")
a = C("a")
f = D("f")
g = E("g")

n.s = g
n.p = g
k.z = f
k.x = n
a.r = k
f.z = g
f.q = n
g.v = f
g.q = a
assert a.r.x.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.p: E = None
        self.txt = txt

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

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

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

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

n = A("n")
k = B("k")
a = C("a")
f = D("f")
g = E("g")

n.s = g
n.p = g
k.z = f
k.x = n
a.r = k
f.z = g
f.q = n
g.v = f
g.q = a
assert a.r.x.s.q.txt == "a"