#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed) << setprecision(15);
  int n;
  long long r;
  scanf("%d %lld", &n, &r);
  map<int, int> mp;
  double sum = 0;
  for (int i = 0; i < (1 << n); i++) {
    int c;
    scanf("%d", &c);
    mp[c]++;
    sum += c;
  }
  printf("%.6f\n", sum / (1 << n));
  for (int i = 0; i < r; i++) {
    int z, g;
    scanf("%d %d", &z, &g);
    sum -= z * mp[z];
    mp[g] = mp[z];
    mp.erase(z);
    sum += g * mp[g];
    printf("%.6f\n", sum / (1 << n));
  }
  return 0;
}
