#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector <int> v[100];
int n,m,x,y;
int ob[100];
int ob1[100];
int a[1000];
int ans,cur;
long long ways;
int c[100];
long long w;
void rek(int x,int *ob,int *ob1,int cur,long long w)
{
if (x==n+1)
{
if (cur>ans)
{
ans=cur;
ways=w;
}
else
if (cur==ans) ways+=w;
} else
if (ob[x]==1) rek(x+1,ob,ob1,cur,w); else
{
int p=0;
for (int i=0;i<v[x].size();i++)
if (v[x][i]>x && !ob[v[x][i]]) p++;
if (!p)
{
if (c[x]==0) w*=2;
ob[x]=1;
cur+=c[x];
rek(x+1,ob,ob1,cur,w);
ob[x]=0;
} else
{
rek(x+1,ob,ob1,cur,w);
ob[x]=1;
for (int i=0;i<v[x].size();i++)
if (v[x][i]>x)
{
ob1[v[x][i]]++;
ob[v[x][i]]=1;
}
cur+=c[x];
rek(x+1,ob,ob1,cur,w);
ob[x]=0;
for (int i=0;i<v[x].size();i++)
if (v[x][i]>x)
{
ob1[v[x][i]]--;
if (!ob1[v[x][i]]) ob[v[x][i]]=0;
}
}
}
}
int main()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)
scanf("%d",&c[i]);
for (int i=0;i<m;i++)
{
scanf("%d%d",&x,&y);
v[y].push_back(x);
v[x].push_back(y);
}
int d=0;
for (int i=1;i<=n;i++)
if (v[i].size()==0 && c[i]==0)
{
d++;
ob[i]=1;
}
else
if (v[i].size()==0) {
cur+=c[i];
ob[i]=1;
}
rek(1,ob,ob1,cur,1);
printf("%d %lld\n",ans,ways*1<<d);
return 0;
}
//I don't like BLACK MAGIC !!!
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KI2luY2x1ZGU8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvciA8aW50PiB2WzEwMF07CmludCBuLG0seCx5OwppbnQgb2JbMTAwXTsKaW50IG9iMVsxMDBdOwppbnQgYVsxMDAwXTsKaW50IGFucyxjdXI7CmxvbmcgbG9uZyB3YXlzOwppbnQgY1sxMDBdOwpsb25nIGxvbmcgdzsKCnZvaWQgcmVrKGludCB4LGludCAqb2IsaW50ICpvYjEsaW50IGN1cixsb25nIGxvbmcgIHcpCnsKCiAgIGlmICh4PT1uKzEpCiAgIHsKICAgICAgIGlmIChjdXI+YW5zKQogICAgICAgewogICAgICAgICAgIGFucz1jdXI7CiAgICAgICAgICAgd2F5cz13OwogICAgICAgfQogICAgICAgZWxzZQogICAgICAgIGlmIChjdXI9PWFucykgd2F5cys9dzsKICAgfSBlbHNlCiAgICBpZiAob2JbeF09PTEpIHJlayh4KzEsb2Isb2IxLGN1cix3KTsgZWxzZQogICAgewogICAgICAgIGludCAgcD0wOwogICAgICAgIGZvciAoaW50IGk9MDtpPHZbeF0uc2l6ZSgpO2krKykKICAgICAgICAgaWYgKHZbeF1baV0+eCAmJiAhb2Jbdlt4XVtpXV0pIHArKzsKCiAgICAgICAgIGlmICghcCkKICAgICAgICAgewogICAgICAgICAgICAgaWYgKGNbeF09PTApIHcqPTI7CiAgICAgICAgICAgICBvYlt4XT0xOwogICAgICAgICAgICAgY3VyKz1jW3hdOwogICAgICAgICAgICAgcmVrKHgrMSxvYixvYjEsY3VyLHcpOwogICAgICAgICAgICAgb2JbeF09MDsKICAgICAgICAgfSBlbHNlCiAgIHsKICAgICAgICAgIHJlayh4KzEsb2Isb2IxLGN1cix3KTsKICAgICAgICAgICAgb2JbeF09MTsKICAgICAgICAgIGZvciAoaW50IGk9MDtpPHZbeF0uc2l6ZSgpO2krKykKICAgICAgICAgICAgaWYgKHZbeF1baV0+eCkKICAgICAgICAgICAgewogICAgICAgICAgICAgIG9iMVt2W3hdW2ldXSsrOwogICAgICAgICAgICAgIG9iW3ZbeF1baV1dPTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VyKz1jW3hdOwogICAgICAgICAgICByZWsoeCsxLG9iLG9iMSxjdXIsdyk7CiAgICAgICAgICAgIG9iW3hdPTA7CiAgICAgICAgICAgIGZvciAoaW50IGk9MDtpPHZbeF0uc2l6ZSgpO2krKykKICAgICAgICAgICAgaWYgKHZbeF1baV0+eCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgb2IxW3ZbeF1baV1dLS07CiAgICAgICAgICAgICAgICBpZiAoIW9iMVt2W3hdW2ldXSkgb2Jbdlt4XVtpXV09MDsKICAgICAgICAgICAgfQogICAgICB9CiAgICB9Cn0KaW50IG1haW4oKQp7CiAgc2NhbmYoIiVkJWQiLCZuLCZtKTsKCiAgZm9yIChpbnQgaT0xO2k8PW47aSsrKQogICAgc2NhbmYoIiVkIiwmY1tpXSk7CgogIGZvciAoaW50IGk9MDtpPG07aSsrKQogIHsKICAgICAgc2NhbmYoIiVkJWQiLCZ4LCZ5KTsKICAgICAgIHZbeV0ucHVzaF9iYWNrKHgpOwogICAgICAgdlt4XS5wdXNoX2JhY2soeSk7CiAgfQoKIGludCBkPTA7CgogZm9yIChpbnQgaT0xO2k8PW47aSsrKQogICBpZiAodltpXS5zaXplKCk9PTAgJiYgY1tpXT09MCkKICAgewogICAgICAgZCsrOwogICAgICAgb2JbaV09MTsKICAgIH0KICAgIGVsc2UKICAgIGlmICh2W2ldLnNpemUoKT09MCkgewogICAgY3VyKz1jW2ldOwogICAgb2JbaV09MTsKICAgIH0KCiAgcmVrKDEsb2Isb2IxLGN1ciwxKTsKCiAgcHJpbnRmKCIlZCAlbGxkXG4iLGFucyx3YXlzKjE8PGQpOwoKcmV0dXJuIDA7Cn0KCi8vSSBkb24ndCBsaWtlIEJMQUNLIE1BR0lDICEhIQ==