class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.u: B = None
        self.p: D = None
        self.txt = txt

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

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

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

e = A("e")
a = B("a")
k = C("k")
i = D("i")
g = D("g")
l = A("l")

e.s = k
e.y = l
e.u = a
e.p = i
a.x = k
k.w = a
i.v = a
i.p = a
g.v = a
g.p = a
l.s = k
l.y = e
l.u = a
l.p = i
assert a.x.w.x.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.u: B = None
        self.p: D = None
        self.txt = txt

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

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

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

e = A("e")
a = B("a")
k = C("k")
i = D("i")
g = D("g")
l = A("l")

e.s = k
e.y = l
e.u = a
e.p = i
a.x = k
k.w = a
i.v = a
i.p = a
g.v = a
g.p = a
l.s = k
l.y = e
l.u = a
l.p = i
assert a.x.w.x.w.x.w.txt == "a"