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

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

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

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

e = A("e")
d = B("d")
l = C("l")
g = D("g")
a = B("a")
n = A("n")

e.y = l
d.y = l
l.s = d
g.x = a
g.w = l
g.q = n
g.p = n
a.y = l
n.y = l
assert n.y.s.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

e = A("e")
d = B("d")
l = C("l")
g = D("g")
a = B("a")
n = A("n")

e.y = l
d.y = l
l.s = d
g.x = a
g.w = l
g.q = n
g.p = n
a.y = l
n.y = l
assert n.y.s.y.s.y.txt == "l"