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

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

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

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

c = A("c")
e = B("e")
i = C("i")
n = D("n")
f = D("f")
k = A("k")
b = A("b")
d = A("d")
g = C("g")
j = B("j")

c.s = d
e.s = n
i.p = e
n.w = f
f.w = n
k.s = c
b.s = c
d.s = k
g.p = j
j.s = f
assert g.p.s.w.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

c = A("c")
e = B("e")
i = C("i")
n = D("n")
f = D("f")
k = A("k")
b = A("b")
d = A("d")
g = C("g")
j = B("j")

c.s = d
e.s = n
i.p = e
n.w = f
f.w = n
k.s = c
b.s = c
d.s = k
g.p = j
j.s = f
assert g.p.s.w.w.w.w.w.w.w.w.txt == "f"