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

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

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

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

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

l.s = a
l.p = f
c.y = e
c.p = k
c.z = f
k.o = a
f.w = k
e.y = c
e.p = k
e.z = f
a.s = l
a.p = f
assert e.z.w.o.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

l.s = a
l.p = f
c.y = e
c.p = k
c.z = f
k.o = a
f.w = k
e.y = c
e.p = k
e.z = f
a.s = l
a.p = f
assert e.z.w.o.s.p.txt == "f"