program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const max=200000;
type part=record
  a,k:int64;
end;
type list=array[1..max] of part;
procedure qsort(lo,hi:int64;var a:list);
procedure sort(l,r:int64);
var
i,j,p:int64;
y:part;
begin
  i:=l; j:=r; p:=a[(l+r) div 2].k;
  repeat
    while a[i].k<p do i:=i+1;
    while a[j].k>p do j:=j-1;
    if i<=j then
    begin
      if a[i].k>a[j].k then
      begin
        y:=a[i]; a[i]:=a[j]; a[j]:=y;
      end;
      inc(i);
      dec(j);
    end;
  until i>=j;
  if l<j then sort(l,j);
  if i<r then sort(i,r);
end;
begin
  randomize;
  sort(lo,hi);
end;
var
n,m,p,s,money,a,k,fish:int64;
i:integer;
x:list;
begin
  assign(input,'fisher.in');
  assign(output,'fisher.out');
  reset(input);
  rewrite(output);
  readln(n,m,p);
  if p>0 then begin write('difficult'); halt(0); end;
  fish:=0;
  for i:=1 to n do
  begin
    readln(a,k);
    inc(fish,k);
  end;
  for i:=1 to m do
  begin
    readln(s,x[i].a,x[i].k);
  end;
  money:=0;
  qsort(1,m,x);
  s:=fish;
  for i:=m downto 1 do
  begin
    if s<x[i].a then
    begin
      inc(money,x[i].k*s);
      s:=0;
      break;
    end;
    inc(money,x[i].k*x[i].a);
    dec(s,x[i].a);
  end;
  write(money);
  close(input);
  close(output);
end.
