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

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

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

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

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

n.w = e
e.o = c
e.s = n
e.w = j
i.p = l
c.r = f
f.r = c
j.w = e
l.p = i
assert f.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

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

n.w = e
e.o = c
e.s = n
e.w = j
i.p = l
c.r = f
f.r = c
j.w = e
l.p = i
assert f.r.r.r.r.r.r.r.txt == "c"