#include <bits/stdc++.h>
struct node {
  int row, col;
  struct node *next;
};
int n, m, r, c;
char temp[1000][1001];
int connected[1000][1000], connectedCounter[1000000], idx = 0;
void push(struct node **head, struct node **tail, int row, int col,
          int *counter) {
  if (row < 0 || col < 0 || row >= n || col >= m || temp[row][col] == '*' ||
      temp[row][col] == '#')
    return;
  if (row - 1 >= 0 && temp[row - 1][col] == '*') (*counter)++;
  if (row + 1 < n && temp[row + 1][col] == '*') (*counter)++;
  if (col - 1 >= 0 && temp[row][col - 1] == '*') (*counter)++;
  if (col + 1 < m && temp[row][col + 1] == '*') (*counter)++;
  struct node *newNode = (struct node *)malloc(sizeof(struct node));
  connected[row][col] = idx;
  temp[row][col] = '#';
  newNode->row = row;
  newNode->col = col;
  newNode->next = NULL;
  if (*head == NULL)
    *head = *tail = newNode;
  else {
    (*tail)->next = newNode;
    *tail = newNode;
  }
}
void pop(struct node **head, struct node **tail) {
  struct node *temp = *head;
  *head = (*head)->next;
  if (*head == NULL) *tail = NULL;
  free(temp);
}
int BFS(struct node **head, struct node **tail) {
  int counter = 0;
  push(head, tail, r, c, &counter);
  while (*head) {
    int row = (*head)->row, col = (*head)->col;
    pop(head, tail);
    push(head, tail, row + 1, col, &counter);
    push(head, tail, row - 1, col, &counter);
    push(head, tail, row, col + 1, &counter);
    push(head, tail, row, col - 1, &counter);
  }
  return counter;
}
int main() {
  int k;
  char map[1000][1001];
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 1000; j++) connected[i][j] = -1;
  }
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", map[i]);
    strcpy(temp[i], map[i]);
  }
  while (k--) {
    struct node *head = NULL, *tail = NULL;
    scanf("%d %d", &r, &c);
    r--;
    c--;
    int ans;
    if (connected[r][c] == -1) {
      ans = BFS(&head, &tail);
      connectedCounter[connected[r][c]] = ans;
    } else
      ans = connectedCounter[connected[r][c]];
    printf("%d\n", ans);
    idx++;
  }
}
