public void solve() throws IOException {
    int n = nextInt();
    int q = nextInt();
    
    int[] distmap = new int[n];
    int[] skips = new int[n];

    Point[] points = new Point[n];
    for (int x = 0; x < n; x++) {
      points[x] = new Point(nextInt(), nextInt());
      if (x != 0) {
        distmap[x] = points[x].dist(points[x - 1]);
      }
    }
    for (int x = 1; x < n - 1; x++) {
      skips[x] = distmap[x + 1] + distmap[x] - points[x + 1].dist(points[x - 1]);
    }
    
    SegmentTree distance = new SegmentTree(n);
    distance.constructSegmentTree(distmap);
    MaxTree skip = new MaxTree(n);
    skip.constructSegmentTree(skips);
    
    for (int x = 0; x < q; x++) {
      String type = nextToken();
      if (type.equals("U")) {
        int i = nextInt() - 1;
        points[i] = new Point(nextInt(), nextInt());
        for (int y = Math.max(i, 1); y < i + 2; y++) {
          distance.update(points[y].dist(points[y - 1]), y, distmap);
        }
        
        for (int y = Math.max(i - 1, 1); y < Math.min(i + 2, n - 1); y++) {
          skip.update(distmap[y + 1] - distmap[y - 1] - points[y + 1].dist(points[y - 1]), y, skips);
        }
      } else {
        int i = nextInt() - 1;
        int j = nextInt() - 1;
        out.println(distance.getSum(i, j) - skip.getSum(i, j));
      } 
    }
  }