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

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

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

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

l = A("l")
k = B("k")
a = C("a")
n = D("n")
f = A("f")

l.s = k
l.x = k
l.y = f
k.t = n
k.w = n
a.p = l
n.s = k
f.s = k
f.x = k
f.y = l
assert f.y.y.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: A = None
        self.x: B = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
a = C("a")
n = D("n")
f = A("f")

l.s = k
l.x = k
l.y = f
k.t = n
k.w = n
a.p = l
n.s = k
f.s = k
f.x = k
f.y = l
assert f.y.y.x.w.txt == "n"