#include<iostream>
using namespace std;
int main(){
    string t, id; int g, n, d, c,td=0, tc=0;
    cin >> t >> id >> g >> n;
    for(int i=0; i<n;; ++1){
        cin >> d >> c;
        if(d<=0 || d>1000 || c<0 || c>1000)
    {
        cout << "Invalid input"; return 0;}
        td += d; tc += c;
    }
    if(td<=0) cout << "Invalid input";
    else cout << fixed << setprecesion (2) <<(double)tc/td;