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

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

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

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

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

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

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

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

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

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

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

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

f.o = d
f.r = d
f.w = d
f.z = n
a.r = f
a.x = e
a.v = i
e.x = d
e.p = g
g.q = n
g.w = n
g.s = e
d.o = n
d.t = n
d.p = n
n.q = g
n.w = g
n.s = e
i.x = d
i.p = g
assert g.q.s.p.s.p.q.q.txt == "g"