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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: B = None
        self.v: A = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: B = None
        self.v: A = None
        self.txt = txt

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

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

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

j.s = d
j.y = d
j.x = l
j.w = a
g.w = j
g.y = d
g.v = l
a.w = n
n.p = j
d.w = j
d.v = j
d.y = g
l.s = d
l.x = j
l.y = g
l.w = a
assert l.y.w.w.w.txt == "n"