class A:
    def __init__(self, txt: str):
        self.y: A = 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.p: D = None
        self.y: D = None
        self.o: B = None
        self.txt = txt

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

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

k.y = f
i.y = c
l.p = n
l.y = n
l.o = i
n.p = l
n.y = f
n.o = f
n.s = i
c.p = n
c.y = n
c.o = i
f.y = k
assert n.p.p.o.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = 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.p: D = None
        self.y: D = None
        self.o: B = None
        self.txt = txt

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

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

k.y = f
i.y = c
l.p = n
l.y = n
l.o = i
n.p = l
n.y = f
n.o = f
n.s = i
c.p = n
c.y = n
c.o = i
f.y = k
assert n.p.p.o.y.y.y.txt == "k"