private boolean helper(int n, boolean turn) {
        if (n <= 3)
            return turn;
            
        Boolean result;
        if (turn)
            result = cache1.get(n);
        else
            result = cache2.get(n);
        if (result != null)
            return result;
        
        if (turn)
            result = helper(n-1, false) || helper(n-2, false) || helper(n-3, false);
        else
            result = helper(n-1, true) && helper(n-2, true) && helper(n-3, true);
            
        if (turn)
            cache1.put(n, result);
        else
            cache2.put(n, result);
        
        return result;
    }