type
  tlist = array [1..50000, 1..2] of longint;

var
  s, s1: tlist;
  n, m, i: longint;
  sum, p: int64;
  f: text;

procedure qsort(var a: tlist);
  
  procedure sort(l, r: longint);
  var
    i, j, x, y: longint;
  begin
    i := l;
    j := r;
    x := a[(l + r) div 2, 2];
    repeat
      while a[i, 2] > x do
        inc(i);
      while x > a[j, 2] do
        dec(j);
      if not (i > j) then
      begin
        y := a[i, 2];
        a[i, 2] := a[j, 2];
        a[j, 2] := y;
        y := a[i, 1];
        a[i, 1] := a[j, 1];
        a[j, 1] := y;
        inc(i);
        j := j - 1;
      end;
    until i > j;
    if l < j then
      sort(l, j);
    if i < r then
      sort(i, r);
  end;

begin
  sort(1, m);
end;

begin
  assign(f, 'fisher.in');
  reset(f);
  readln(f, n, m, p);
  for i := 1 to n do 
  begin
    readln(f, s[i, 1], s[i, 2]);
  end;
  for i := 1 to m do 
  begin
    readln(f, p, s1[i, 1], s1[i, 2]);
  end;
  close(f);
  for i := 1 to n do 
  begin
    sum := sum + s[i, 2];
  end;
  qsort(s1);
  p := 0;
  i:=1;
  while (sum>0) and (i<=n) do 
  begin
    if sum > s1[i, 1] then begin
      sum := sum - s1[i, 1]; 
      p := p + s1[i, 1] * s1[i, 2];
    end
    else begin
      p := p + s1[i, 2] * sum; 
      sum := 0; 
    end;
    i:=i+1;
  end;
  assign(f, 'fisher.out');
  rewrite(f);
  writeln(f, p);
  close(f);
end.