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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: D = None
        self.z: E = None
        self.u: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: A = None
        self.z: E = None
        self.u: E = None
        self.q: C = None
        self.txt = txt

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

f.s = n
f.q = i
n.p = f
i.p = a
i.z = a
i.o = k
i.u = k
k.o = n
k.x = n
k.y = i
k.r = f
k.p = f
g.r = f
g.x = f
g.z = a
g.u = a
g.q = i
a.r = f
a.x = f
a.z = g
a.u = g
a.q = i
assert k.y.u.y.p.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: D = None
        self.z: E = None
        self.u: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: A = None
        self.z: E = None
        self.u: E = None
        self.q: C = None
        self.txt = txt

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

f.s = n
f.q = i
n.p = f
i.p = a
i.z = a
i.o = k
i.u = k
k.o = n
k.x = n
k.y = i
k.r = f
k.p = f
g.r = f
g.x = f
g.z = a
g.u = a
g.q = i
a.r = f
a.x = f
a.z = g
a.u = g
a.q = i
assert k.y.u.y.p.u.q.txt == "i"