#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    char arr[100000];cin >> arr;
    int sum = 0;
    for(int i = 0; i < strlen(arr); i++)
    {
        if (arr[i] == '1')
            sum += a1;
        else if (arr[i] == '2')
            sum += a2;
        else if (arr[i] == '3')
            sum += a3;
        else
            sum += a4;
    }
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
	string arr;
	cin >> arr;
	int sum = 0;
	sum += a1*count(arr.begin(), arr.end(), '1') + a2*count(arr.begin(), arr.end(), '2') + a3*count(arr.begin(), arr.end(), '3') + a4*count(arr.begin(), arr.end(), '4');
	cout << sum << endl;
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    char arr[100000];cin >> arr;
    int sum = 0;
    if (a1 == 0 && a2 == 0 && a3 == 0 && a4 == 0)
    {
        cout << 0 << endl; return 0;
    }
    for(int i = 0; i < strlen(arr); i++)
    {
        if (arr[i] == '1')
            sum += a1;
        else if (arr[i] == '2')
            sum += a2;
        else if (arr[i] == '3')
            sum += a3;
        else
            sum += a4;
    }
    cout << sum << endl;
    return 0;
}


#include<iostream>
#include<sstream>
using namespace std;
int main(){
	int arr[5], x;
	int ans = 0;
	string s;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];
	cin >> s;
	for (int j = 0; j < s.size(); j++){
		stringstream ss;
		ss << s[j];
		ss >> x;
		ans += arr[x-1];
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int arr[5];
	int ans = 0;
	string s;
	for (int i = 1; i < 5; i++)
		cin >> arr[i];
	cin >> s;
	for (int j = 0; j < s.size(); j++){
		ans += arr[s[j] - '0'];
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<sstream>
using namespace std;
int main(){
	int arr[5], x;
	long long ans = 0;
	string s;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];
	cin >> s;
	for (int j = 0; j < s.size(); j++){
		stringstream ss;
		ss << s[j];
		ss >> x;
		ans += (long long)arr[x-1];
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
int *a,x,sum=0;
	a=new int[4];

	for(int i=0;i<4;++i)
	{
		cin>>a[i];
	}

	string s;
    cin>>s;

    for(int j=0;j<s.size();++j)
	{
	 	switch(s.at(j))
	 	{
	 		case '1' : sum+=a[0];	break;
			case '2' : sum+=a[1];	break;
			case '3' : sum+=a[2];	break;
			case '4' : sum+=a[3];	break;
		}
	}
	 cout<<sum;
}

/*	int *a,x,sum=0;
	a=new int[4];

	for(int i=1;i<=4;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=1;i<=4;++i)
	   	{
	   		if(x==i)
			   {
				  sum+=a[i];
			   }
		}

	 }

	   cout<<sum;
	}

error runtime dad vli dorost boud*/


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
	int *a,x,sum=0;
	a=new int[4];

	for(int i=1;i<=4;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=1;i<=4;++i)
	   	{
	   		if(x==i)
			   {
				  sum+=a[i];
			   }
		}

	 }

	   cout<<sum;
	}


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
/*	int *a,x,sum=0;
	a=new int[4];

	for(int i=1;i<=4;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=1;i<=4;++i)
	   	{
	   		if(x==i)
			   {
				  sum+=a[i];
			   }
		}

	 }

	   cout<<sum;
	}

error runtime dad vli dorost boud*/
int *a,x,sum=0;
	a=new int[4];

	for(int i=0;i<4;++i)
	{
		cin>>a[i];
	}

	string s;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	 	switch(s.at(j))
	 	{
	 		case '1' : sum+=a[0];	break;
			case '2' : sum+=a[1];	break;
			case '3' : sum+=a[2];	break;
			case '4' : sum+=a[3];	break;
		}
	 }
	 cout<<sum;
}


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
	int *a,x,sum=0;
	a=new int[4];

	for(int i=1;i<5;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=1;i<5;++i)
	   	{
	   		if(x==i)
			   {
				  sum+=a[i];
			   }
		}

	 }

	   cout<<sum;
	}


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
void result();
int main(){
	result();
	}
inline void result(){
	int *a,x,sum=0;
	a=new int[4];

	for(int i=1;i<=4;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=1;i<=4;++i)
	   	{
	   		if(x==i)
			   {
				  sum+=a[i];
			   }
		}

	 }

	   cout<<sum;
}


#include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
	int *a,x,sum=0;
	a=new int[4];

	for(int i=0;i<4;++i)
	{
		cin>>a[i];
	}

	string s,s1;
    cin>>s;
//	bool result=false;

	 for(int j=0;j<s.size();++j)
	 {
	   	s1=s[j];
	    x=atoi(s1.c_str());

	   	for(int i=0;i<4;++i)
	   	{
	   		if(x==a[i])
			   {
				  sum+=i+1;
			   }
		}

	 }

	   cout<<sum;
	}


#include <iostream>
#include <string>
using namespace std;
int main()
{
	int arr[5];
	string s;
	int sum = 0;
	for (int i = 1; i <= 4; i++)
	{
		cin >> arr[i];
	}
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		sum += arr[s[i] - '0'];
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int sum =0;
    int arr[4];
    string str;
    for(int i=0;i<4;i++)
    {
        cin>>arr[i];
    }
    cin>>str;
    for(int j=0;j<str.length();j++)
    {
        sum+=arr[str[j]-'0'-1];
    }
    cout<<sum;

    return 0;
}


#include<iostream>
#include<string>
using namespace std;
void task1();
void task2();
void task3();
void main() {
	task3();
}
void task1() {
	long long  n, m, k, l;//объявляем переменные
	cin >> n >> m >> k >> l;//ввод переменных
	n /= m;
	m = (k + l + m - 1) / m;//Основная формула следуя из условия задания
	cout << (n >= m ? m : -1);//вывод с проверкой на результат Основной формулы
}
void task2() {
	long long n, ans = 0;//объявление переменных
	cin >> n;;//ввод переменной
	while (n > 9) {//Алгоритм разбиения числа
		n -= 9;
		ans += 9;
		ans += n % 10;
		n /= 10;
	}
	cout << ans + n << endl;//вывод конечного числа
}
void task3() {
	long long i, n = 0, a[4];
	string s;
	for (i = 0; i < 4; i++)cin >> a[i];
	getline(cin,s);
	for (i = 0; i < s.size(); i++) n += a[s[i] - '1'];
	cout << n;
}


#include<iostream>
#include<string>
using namespace std;
void task1();
void task2();
void task3();
void main() {
	task3();
}
void task1() {
	long long  n, m, k, l;//объявляем переменные
	cin >> n >> m >> k >> l;//ввод переменных
	n /= m;
	m = (k + l + m - 1) / m;//Основная формула следуя из условия задания
	cout << (n >= m ? m : -1);//вывод с проверкой на результат Основной формулы
}
void task2() {
	long long n, ans = 0;//объявление переменных
	cin >> n;;//ввод переменной
	while (n > 9) {//Алгоритм разбиения числа
		n -= 9;
		ans += 9;
		ans += n % 10;
		n /= 10;
	}
	cout << ans + n << endl;//вывод конечного числа
}
void task3() {
	long long i, n = 0, a[4];
	string s;
	for (i = 0; i < 4; i++)cin >> a[i];
	cin >> s;
	for (i = 0; i < s.length(); i++) n += a[s[i] - '1'];
	cout << n;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int a1,a2,a3,a4;
    string b;
    cin>>a1>>a2>>a3>>a4;
    cin>>b;
    int sum=0;
    for(int i=0;b[i]!='\0';i++)
    {
        if(b[i]==a1)
        sum=sum+a1;
        if(b[i]==a2)
        sum=sum+a2;
        if(b[i]==a3)
        sum=sum+a3;
        if(b[i]==a4)
        sum=sum+a4;
    }
    cout<<sum;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    char a1,a2,a3,a4;
    string b;
    cin>>a1>>a2>>a3>>a4;
    cin>>b;
    int sum=0;
    for(int i=0;b[i]!='\0';i++)
    {
        if(b[i]==a1)
        sum=sum+a1;
        if(b[i]==a2)
        sum=sum+a2;
        if(b[i]==a3)
        sum=sum+a3;
        if(b[i]==a4)
        sum=sum+a4;
    }
    cout<<sum;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int a1,a2,a3,a4;
    string b;
    cin>>a1>>a2>>a3>>a4;
    cin>>b;
    int sum=0;
    for(int i=0;b[i]!='\0';i++)
    {
        if(b[i]=='a1')
        sum=sum+a1;
        if(b[i]=='a2')
        sum=sum+a2;
        if(b[i]=='a3')
        sum=sum+a3;
        if(b[i]=='a4')
        sum=sum+a4;
    }
    cout<<sum;
}


#include <iostream>

using namespace std;

int arr[4], sum;

string s;

int main() {

    cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> s;

    for (int i = 0; i < s.size(); i++) {

        sum += arr[s[i] - 49];

    }

    cout << sum;

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int arr[4];
    int sum=0;
    string s;
    cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>s;
    for (int i = 0; i < s.size(); i++)
    {
        sum += arr[s[i] - 49];
    }
    cout << sum;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int arr[4], sum;
    string s;
    cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>s;
    for (int i = 0; i < s.size(); i++)
    {
        sum += arr[s[i] - 49];
    }
    cout << sum;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    char a1,a2,a3,a4;
    string b;
    cin>>a1>>a2>>a3>>a4;
    cin>>b;
    int sum=0;
    for(int i=0;b[i]!='\0';i++)
    {
        if(b[i]==a1)
        sum=sum+int(a1);
        if(b[i]==a2)
        sum=sum+int(a2);
        if(b[i]==a3)
        sum=sum+int(a3);
        if(b[i]==a4)
        sum=sum+int(a4);
    }
    cout<<sum;
}


#include<iostream>
#include<string>
using namespace std;
void main()
{
	int sum=0;
     int arr[4];
	 string num;
	 for(int i=0 ;i<4;i++)
		 cin>>arr[i];
	 cin>>num ;

	 for(int q=0;q<num.length();q++)
		 sum+=arr[num[q]-49];
	 cout<<sum;

}


#include<iostream>
#include<string>
using namespace std;
void main()
{
	int sum=0;
     int arr[4];
	 string num;
	 for(int i=0 ;i<4;i++)
		 cin>>arr[i];
	 cin>>num ;

	 for(int q=0;q<num.length();q++)
		 sum+=arr[num[q]-49];
	 cout<<sum;


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
//#include <stack>
#include <map>
//#include <set>
//#include <unordered_set>
using namespace std;
#define ff(i,m) for(auto i=m.begin();i!=m.end();++i)
#define fr(i,m) for(auto i=m.rbegin();i!=m.rend();++i)
#define f0(i,n) for(decltype(n) i=0;i<n;++i)
#define f1(i,n) for(decltype(n) i=1;i<n;++i)
#define ffor(i,s,n) for(int i=s;i<n;++i)
#define rfor(i,s,n) for(int i=s;i>n;--i)
inline int getline(char* s);
void getint(int &value);
int getint();
typedef long long ll;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef pair<int, int> P;
void u32toa(uint value, char* buffer);
void i32toa(int value, char* buffer);

class CodeForces
{
    char s[100024];

    inline void print(int val)
    {
        char number[12];
        u32toa(val, number);
        puts(number);
    }

    void print(double d)
    {
        double i, f;
        d += 0.0000005;
        i = modf(d, &f);
        printf("%d.%06d\n", (int)f, (int)(i*1000000.0));
    }

    void solve()
    {
        int l, sum = 0, a[8];
        getint(a[1]); getint(a[2]); getint(a[3]); getint(a[4]);

        l = getline(s);
        f0(i,l) sum += a[s[i] - '0'];
        print(sum);
    }

public:
    void Run()
    {
        solve();
    }
};

void main()
{
    //std::ios_base::sync_with_stdio(false);
    //cin.tie(0);
    CodeForces &cf = *new CodeForces();
#ifdef _DEBUG
    //freopen("out.txt", "wt", stdout);
    //freopen("input.txt", "rt", stdin);
    ll s = __rdtsc();
#endif
    //CodeForces cf;
    cf.Run();
#ifdef _DEBUG
    //fprintf(stderr, "%f\n", (__rdtsc() - s)/1e9);
    system("pause");
#endif
}

void i32toa(int value, char* buffer)
{
    uint u = static_cast<uint>(value);
    if (value < 0)
    {
        *buffer++ = '-';
        u = ~u + 1;
    }
    u32toa(u, buffer);
}

void u32toa(uint value, char* buffer)
{
    char temp[10];
    char *p = temp;
    do
    {
        *p++ = char(value % 10) + '0';
        value /= 10;
    } while (value > 0);

    do
    {
        *buffer++ = *--p;
    } while (p != temp);

    *buffer = '\0';
}

inline int getline(char* s)
{
    int c=0;
    while ((s[c] = _getchar_nolock()) != 10) c++; s[c]=0;
    return c;
}

inline void getint(int &value)
{
    int i;
    while ((i = _getchar_nolock()) < '0' || i > '9');
    value = i-'0';
    while ((i = _getchar_nolock()) >= '0' && i <= '9') value = value * 10 + i - '0';
}

inline int getint()
{
    int i;
    getint(i);
    return i;
}


#include <iostream>
using namespace std;

int main()
{
    char c;
    int sum = 0, a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];

    while(scanf("%1s", &c) > 0)
    {
        sum += a[c - '0' - 1];
    }

    cout << sum << endl;

    return 0;
}


#include <iostream>
using namespace std;
int frq[5],a[5];
int main()
{
    int s,cnt,sol=0;
    for (int i = 1; i < 5; i++)
    {
        cin>>a[i];
    }
    cin>>s;
    while(s>=1)
    {
        if(s>4){
            cnt = s % 10;
            frq[cnt]++;
            s = s / 10;
            continue;
        }
        cnt=s;
        frq[cnt]++;
        s = s / 10;
    }
    for (int i = 1; i < 5; i++)
    {
       sol+=frq[i]*a[i];
    }
    cout<<sol;
    return 0;
}


#include <iostream>
using namespace std;
int frq[5],a[5];
int main()
{
    int cnt,sol=0;
    long long s;
    for (int i = 1; i < 5; i++)
    {
        cin>>a[i];
    }
    cin>>s;
    while(s>=1)
    {
        if(s>4){
            cnt = s % 10;
            frq[cnt]++;
            s = s / 10;
            continue;
        }
        cnt=s;
        frq[cnt]++;
        s = s / 10;
    }
    for (int i = 1; i < 5; i++)
    {
       sol+=frq[i]*a[i];
    }
    cout<<sol;
    return 0;
}


#include <iostream>
using namespace std;
int frq[4],a[4];
int main()
{
    int s,cnt,sol=0;
    for (int i = 1; i < 5; i++)
    {
        cin>>a[i];
    }
    cin>>s;
    while(s>=1)
    {
        if(s>4){
            cnt = s % 10;
            frq[cnt]++;
            s = s / 10;
            continue;
        }
        cnt=s;
        frq[cnt]++;
        s = s / 10;
    }
    for (int i = 1; i < 5; i++)
    {
       sol+=frq[i]*a[i];
    }
    cout<<sol;
    return 0;
}


#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int frq[5],a[5];
int main()
{
    int sol=0;
    string s;
    for (int i = 1; i < 5; i++)
    {
        cin>>a[i];
    }
    cin>>s;
    int x=s.length(),y;
    while(x--)
    {   y=s[x]-48;
        frq[y]++;
    }
    for (int i = 1; i < 5; i++)
    {
       sol+=frq[i]*a[i];
    }
    cout<<sol;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int x,y,z,w;
int sum=0;
string s;
cin>>x>>y>>z>>w;
cin>>s;
for(int i=0;i<s.length();i++){
	if(s[i]=='1'){
	sum+=x;}
	else if(s[i]=='2'){
	sum+=y;}
	else if(s[i]=='3'){
	sum+=z;}
	else if(s[i]=='4'){
	sum+=w;}
}
cout<<sum<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int x,y,z,w;
int sum=0;
string s;
cin>>x>>y>>z>>w;
cin>>s;
for(int i=0;i<s.size();i++){
	if(s[i]==1)sum+=x;
	if(s[i]==2)sum+=y;
	if(s[i]==3)sum+=z;
	if(s[i]==4)sum+=w;
}
cout<<sum<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int x,y,z,w;
int sum=0;
string s;
cin>>x>>y>>z>>w;
cin>>s;
for(int i=0;i<s.length();i++){
	if(s[i]=="1"){
	sum+=x;}
	else if(s[i]=="2"){
	sum+=y;}
	else if(s[i]=="3"){
	sum+=z;}
	else if(s[i]=="4"){
	sum+=w;}
}
cout<<sum<<endl;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>

using namespace std;

int main(){
    char ss[100000];
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    string s; cin >> s;
    strcpy_s(ss, s.c_str());
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (ss[i] == '1')  ans+= a1;
        if (ss[i] == '2')  ans += a2;
        if (ss[i] == '3') ans += a3;
        if (ss[i] == '4') ans += a4;
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>

using namespace std;

int main(){
    char ss[100000];
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    string s; cin >> s;
    //strcpy_s(ss, s.c_str());
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '1')  ans+= a1;
        if (s[i] == '2')  ans += a2;
        if (s[i] == '3') ans += a3;
        if (s[i] == '4') ans += a4;
    }

    cout << ans << endl;
    cout << ss[0] << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>

using namespace std;

int main(){
    char ss[100000];
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    string s; cin >> s;
    strcpy(ss, s.c_str());
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (ss[i] == '1')  ans+= a1;
        if (ss[i] == '2')  ans += a2;
        if (ss[i] == '3') ans += a3;
        if (ss[i] == '4') ans += a4;
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>

using namespace std;

int main(){
    char ss[100000];
    int a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4;
    string s; cin >> s;
   // strcpy_s(ss, s.c_str());
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '1')  ans+= a1;
        if (s[i] == '2')  ans += a2;
        if (s[i] == '3') ans += a3;
        if (s[i] == '4') ans += a4;
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
using namespace std;
#include "string"
int main ()
{
	int a1,a2,a3,a4;
	cin>>a1>>a2>>a3>>a4;
	char S[100010];
	cin>>S;
	int L=strlen(S);
	int cal=0;
	int strip;
	for(int i=0;i<L;i++)
	{
	  strip= S[i]-'0';
	  if(strip==1) cal+=a1;
	  else if(strip==2) cal+=a2;
	  else if(strip==3) cal+=a3;
	  else if(strip==4) cal+=a4;

	}
	cout<<cal;

return 0;
}


#include <iostream>
using namespace std;
#include "string"
int main ()
{
	int a1,a2,a3,a4;
	cin>>a1>>a2>>a3>>a4;
	char S[100000];
	cin>>S;
	int L=strlen(S);
	int cal=0;
	int strip;
	for(int i=0;i<L;i++)
	{
	  strip= S[i]-'0';
	  if(strip==1) cal+=a1;
	  else if(strip==2) cal+=a2;
	  else if(strip==3) cal+=a3;
	  else if(strip==4) cal+=a4;

	}
	cout<<cal;

return 0;
}


#include<iostream>

using namespace std;

int main(){
    int a[5];
    for (int i = 1; i <= 4; i ++)
        cin >> a[i];
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0 ;i < s.size(); i ++)
        sum += a[s[i]-'0'];
    cout << sum << endl;
    return 0;
}


#include<iostream>
#include <string>
#include <string.h>

using namespace std;

int main(){
    int a[5];
    for (int i = 1; i <= 4; i ++)
        cin >> a[i];
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0 ;i < s.size(); i ++)
        sum += a[s[i]-'0'];
    cout << sum << endl;
    return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    int a1,a2,a3,a4,cal,len;
    int i;
    char s[7];
    scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
    scanf("%s",s);
    i=0;
    len=strlen(s);
    cal=0;
    for(i=0;i<len;i++){
        if(s[i]=='1'){
            cal+=a1;
        }else if(s[i]=='2'){
            cal+=a2;
        }else if(s[i]=='3'){
            cal+=a3;
        }else if(s[i]=='4'){
            cal+=a4;
        }
    }
    printf("%d\n",cal);
}


#include <stdio.h>
#include <string.h>
int main()
{
    double a1,a2,a3,a4,cal,len;
    int i;
    char s[7];
    scanf("%lld %lld %lld %lld",&a1,&a2,&a3,&a4);
    scanf("%s",s);
    i=0;
    len=strlen(s);
    cal=0;
    for(i=0;i<len;i++){
        if(s[i]=='1'){
            cal+=a1;
        }else if(s[i]=='2'){
            cal+=a2;
        }else if(s[i]=='3'){
            cal+=a3;
        }else if(s[i]=='4'){
            cal+=a4;
        }
    }
    printf("%lld\n",cal);
}


#include <stdio.h>
#include <string.h>
int main()
{
    int a1,a2,a3,a4,cal,len;
    int i;
    char s[100010];
    scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
    scanf("%s",s);
    len=strlen(s);
    cal=0;
    for(i=0;i<len;i++){
        if(s[i]=='1'){
            cal+=a1;
        }else if(s[i]=='2'){
            cal+=a2;
        }else if(s[i]=='3'){
            cal+=a3;
        }else if(s[i]=='4'){
            cal+=a4;
        }
    }
    printf("%d\n",cal);
}


#include <stdio.h>
#include <string.h>
int main()
{
    double a1,a2,a3,a4,cal,len;
    int i;
    char s[50];
    scanf("%lld %lld %lld %lld",&a1,&a2,&a3,&a4);
    scanf("%s",s);
    i=0;
    len=strlen(s);
    cal=0;
    for(i=0;i<len;i++){

        if(s[i]=='1'){
            cal+=a1;
        }else if(s[i]=='2'){
            cal+=a2;
        }else if(s[i]=='3'){
            cal+=a3;
        }else if(s[i]=='4'){
            cal+=a4;
        }
    }
    printf("%lld\n",cal);
}


#include <stdio.h>
#include <string.h>
int main()
{
    int a1,a2,a3,a4,cal,i,len;

    char s[100];
    scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
    scanf("%s",s);
    len=strlen(s);
    cal=0;
    for(i=0;i<len;i++){
        if(s[i]=='1'){
            cal+=a1;
        }else if(s[i]=='2'){
            cal+=a2;
        }else if(s[i]=='3'){
            cal+=a3;
        }else if(s[i]=='4'){
            cal+=a4;
        }
    }
    printf("%d\n",cal);
}


#include<iostream>

using namespace std;

int main(){
    int a[5];
    for (int i = 1; i <= 4; i ++)
        cin >> a[i];
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0 ;i < s.size(); i ++)
        sum += a[s[i]-'0'];
    cout << sum << endl;

    return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){

 int  arr[4];

int count=0;
	for (int i = 0; i < 4; i++)
	{
		cin>>arr[i];
	}
	string s;
	cin>>s;
	for (int i = 0; i < s.size(); i++)
	{
		int z=s[i]-'0';
		count+=arr[z-1];
	}
	cout<<count<<endl;

	return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int q[5];
    string s;
    cin>>q[1]>>q[2]>>q[3]>>q[4];
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        int t=s[i]-'0';
        sum+=q[t];
    }
    cout<<sum<<endl;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int q[5];
    string s;
    while(scanf("%d%d%d%d",&q[1],&q[2],&q[3],&q[4]))
    {
        cin>>s;
        int sum=0;
        for(int i=0;i<s.length();i++)
        {
            int t=s[i]-'0';
            sum+=q[t];
        }
        cout<<sum<<endl;
    }
}


#include<iostream>
using namespace std;
int main()
{
    int q[5];
    int i;
    string s;
    for(i=1;i<5;i++)
        cin>>q[i];
    cin>>s;
    int sum=0;
    for(i=0;i<s.length();i++)
    {
        int t=s[i]-'0';
        sum+=q[t];
    }
    cout<<sum<<endl;
}


#include<iostream>
using namespace std;
int main()
{
    int q[5];
    string s;
    for(int i=1;i<5;i++)
        cin>>q[i];
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        int t=s[i]-'0';
        sum+=q[t];
    }
    cout<<sum<<endl;
}


#include<iostream>
using namespace std;
int main()
{
    int q[5];
    int i;
    char s[10001];
    for(i=1;i<5;i++)
        cin>>q[i];
    cin>>s;
    int sum=0;
    for(i=0;i<strlen(s);i++)
    {
        int t=s[i]-'0';
        sum+=q[t];
    }
    cout<<sum<<endl;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int q[5];
    string s;
    while(cin>>q[1])
    {
        cin>>q[2]>>q[3]>>q[4];
        cin>>s;
        int sum=0;
        for(int i=0;i<s.length();i++)
        {
            int t=s[i]-'0';
            sum+=q[t];
        }
        cout<<sum<<endl;
    }
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int q[5];
    int i;
    string s;
    for(i=1;i<5;i++)
        cin>>q[i];
    cin>>s;
    int sum=0;
    for(i=0;i<strlen(s);i++)
    {
        int t=s[i]-'0';
        sum+=q[t];
    }
    cout<<sum<<endl;
}


#include<iostream>
using namespace std;
int main()
{
    int q[5];
    string s;
    while(scanf("%d%d%d%d",&q[1],&q[2],&q[3],&q[4]))
    {
        cin>>s;
        int sum=0;
        for(int i=0;i<s.length();i++)
        {
            int t=s[i]-'0';
            sum+=q[t];
        }
        cout<<sum<<endl;
    }
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int q[5];
	int i;
	string s;
	for(i=1;i<5;i++)
		cin>>q[i];
	cin>>s;
	int sum=0;
	for(i=0;i<s.length();i++)
	{
		int t=s[i]-'0';
		sum+=q[t];
	}
	cout<<sum<<endl;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int q[5];
    string s;
    while(cin>>q[1]>>q[2]>>q[3]>>q[4])
    {
        cin>>s;
        int sum=0;
        for(int i=0;i<s.length();i++)
        {
            int t=s[i]-'0';
            sum+=q[t];
        }
        cout<<sum<<endl;
    }
}


#include<stdio.h>
#include<string.h>
int main()
{
	int calories[100],total=0,inNumber;
	char tap[1000];
	for(int i = 1;i<=4;i++)
	{
		scanf("%d",&calories[i]);
	}
	scanf("%s",tap); getchar();
	int len = strlen(tap);
	for(int i = 0;i<len;i++)
	{
		inNumber = tap[i]-'0';
		total = total+calories[inNumber];
	}
	printf("%d",total);

}


#include<stdio.h>
#include<string.h>
int main()
{
	int calories[6],total=0,inNumber;
	char tap[10005];
	for(int i = 1;i<=4;i++)
	{
		scanf("%d",&calories[i]);
	}
	scanf("%s",tap); getchar();
	int len = strlen(tap);
	for(int i = 0;i<len;i++)
	{
		inNumber = tap[i]-'0';
		total = total+calories[inNumber];
	}
	printf("%d",total);

}


#include<stdio.h>
#include<string.h>
int main()
{
	int calories[6],total=0,inNumber;
	char tap[100005];
	for(int i = 1;i<=4;i++)
	{
		scanf("%d",&calories[i]);
	}
	scanf("%s",tap); getchar();
	int len = strlen(tap);
	for(int i = 0;i<len;i++)
	{
		inNumber = tap[i]-'0';
		total = total+calories[inNumber];
	}
	printf("%d",total);

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

using namespace std;

int cal=0;
int main()
{
    int x[4] , i ;
    char n[100000];
    for (i=0; i<4; i++)
    {
        scanf("%d", &x[i]);

    }
int temp = x[0];

     scanf("%s" ,&n);

   i=0;
   while(n[i] != '\0')
   {

        switch(n[i])
        {
            case '1' : cal  += temp ;
            break;
             case '2' : cal  += x[1];
            break;
             case '3' : cal  += x[2];
            break;
            case '4' : cal  +=  x[3];
            break;

        }
    i++;
    }
 //  printf("%d\n" , sizeof(n)/sizeof(char));
      printf("%d\n" , cal);

    return 0;

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

using namespace std;

int cal=0;
int main()
{
    int x[4] , i ;
    char n[6];
    for (i=0; i<4; i++)
    {
        scanf("%d", &x[i]);

    }
int temp = x[0];

     scanf("%s" ,&n);

   i=0;
   while(n[i] != '\0')
   {

        switch(n[i])
        {
            case '1' : cal  += temp ;
            break;
             case '2' : cal  += x[1];
            break;
             case '3' : cal  += x[2];
            break;
            case '4' : cal  +=  x[3];
            break;

        }
    i++;
    }
 //  printf("%d\n" , sizeof(n)/sizeof(char));
      printf("%d\n" , cal);

    return 0;

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

using namespace std;

int cal=0;
int main()
{
    int x[4] , i ;
    char n[1000000];
    for (i=0; i<4; i++)
    {
        scanf("%d", &x[i]);

    }
int temp = x[0];

     scanf("%s" ,&n);

   i=0;
   while(n[i] != '\0')
   {

        switch(n[i])
        {
            case '1' : cal  += temp ;
            break;
             case '2' : cal  += x[1];
            break;
             case '3' : cal  += x[2];
            break;
            case '4' : cal  +=  x[3];
            break;

        }
    i++;
    }
 //  printf("%d\n" , sizeof(n)/sizeof(char));
      printf("%d\n" , cal);

    return 0;

}


#include<iostream>
#include<iomanip>
#include<set>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<fstream>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<iterator>
using namespace std;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define repi(n)  for(int i = 0; i < (int)(n); ++i)
#define repj(n)  for(int j = 0; j < (int)(n); ++j)
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define reprng(i,a,b) for(int i = a; i <= (int)(b); ++i)
#define reprngr(i,n,a) for(int i = n;i >= (int)(a); --i)
#define For(it,c) for(auto  it=c.begin();it!=c.end();++it)
#define log2(n) (log10((long double)n) / log10((long double)2))
#define swap(a,b) a = a + b, b = a - b, a = a - b
#define mp make_pair
typedef long long ll;

int main()
{

	int calories[4];
	int ans = 0;
	repi(4)
		cin >> calories[i];
	string s;
	cin >> s;
	repi(sz(s))
		ans += calories[s[i] - '0' - 1];
	cout << ans;

	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int calories[5];
	int totalCalories = 0;
	string s;
	for (int i = 1; i <= 4; ++i)
		cin >> calories[i];
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		totalCalories += calories[s[i] - '0'] ;
	}

    cout<< totalCalories;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
typedef int Calorie;
//Function to Compute Calories Recursively.
int ComputeCalories(Calorie*,string,int);
void main(void)
{
string StripInfo;
Calorie CalorieArr[4];
     cin >> CalorieArr[0] >> CalorieArr[1]
          >> CalorieArr[2] >> CalorieArr[3];
     cin >> StripInfo;
     cout << ComputeCalories(CalorieArr, StripInfo,StripInfo.size()-1) << endl;
}
int ComputeCalories(Calorie* CalorieArr, string StriInfo,int Curr)
{
int CorresIndex = 0;
    switch(StriInfo[Curr])
    {
        case('1'):
        {
            CorresIndex = 0;
            break;
        }
        case('2'):
        {
            CorresIndex = 1;
            break;
        }
        case('3'):
        {
            CorresIndex = 2;
            break;
        }
        case('4'):
        {
            CorresIndex = 3;
            break;
        }
    }
    if (Curr == 0)
         return CalorieArr[CorresIndex];
    else return CalorieArr[CorresIndex] +
        ComputeCalories(CalorieArr, StriInfo, Curr - 1);
}


#include<iostream>
#include<string>
using namespace std;
typedef int Calorie;
void main(void)
{
string StripInfo;
Calorie CalorieSum = 0,CalorieArr[4];
     cin >> CalorieArr[0] >> CalorieArr[1]
          >> CalorieArr[2] >> CalorieArr[3];
     cin >> StripInfo;
     for (int X = 0; X < StripInfo.size(); ++X)
     {
         if (StripInfo[X] == '1')
             CalorieSum += CalorieArr[0];
         else if (StripInfo[X] == '2')
             CalorieSum += CalorieArr[1];
         else if (StripInfo[X] == '3')
             CalorieSum += CalorieArr[2];
         else
             CalorieSum += CalorieArr[3];
     }
     cout << CalorieSum << endl;
}


#include<iostream>
#include<string>
using namespace std;
typedef int Calorie;
//Function to Compute Calories Recursively.
int ComputeCalories(Calorie*,string,int);
void main(void)
{
string StripInfo;
Calorie CalorieArr[4];
     cin >> CalorieArr[0] >> CalorieArr[1]
          >> CalorieArr[2] >> CalorieArr[3];
     cin >> StripInfo;
     cout << ComputeCalories(CalorieArr, StripInfo,StripInfo.size()-1) << endl;
}
int ComputeCalories(Calorie* CalorieArr, string StriInfo,int Curr)
{
int CorresIndex = 0;
    switch(StriInfo[Curr])
    {
        case(1):
        {
            CorresIndex = 0;
            break;
        }
        case(2):
        {
            CorresIndex = 1;
            break;
        }
        case(3):
        {
            CorresIndex = 2;
            break;
        }
        case(4):
        {
            CorresIndex = 4;
            break;
        }
    }
    if (Curr == 0)
         return CalorieArr[CorresIndex];
    else return CalorieArr[CorresIndex] +
        ComputeCalories(CalorieArr, StriInfo, Curr - 1);
}


#include<string>
#include<iostream>
using namespace std;
int main()
{
	int a1,a2,a3,a4,total=0;
	char s[100002];
	cin>>a1>>a2>>a3>>a4>>s;
    //unsigned long long num=s.size();
    //char* array=new char(num);
	int num=strlen(s);
    for(int i=0;i<num;i++)
	{
		//array[i]=s.at(i);
		if(s[i]=='1') total+=a1;
		if(s[i]=='2') total+=a2;
		if(s[i]=='3') total+=a3;
		if(s[i]=='4') total+=a4;

	}
	cout<<total<<endl;
	return 0;
}


#include<string>
#include<iostream>
using namespace std;
int main()
{
	int a1,a2,a3,a4,total=0;
	string s;
	cin>>a1>>a2>>a3>>a4>>s;
    unsigned long long num=s.size();
    char* array=new char(num);
    for(unsigned long long i=0;i<num;i++)
	{
		array[i]=s.at(i);
		if(array[i]=='1') total+=a1;
		if(array[i]=='2') total+=a2;
		if(array[i]=='3') total+=a3;
		if(array[i]=='4') total+=a4;

	}
	cout<<total<<endl;
	return 0;
}


#include<string>
#include<iostream>
using namespace std;
int main()
{
	int a1,a2,a3,a4,total=0;
	string s;
	cin>>a1>>a2>>a3>>a4>>s;
    long long num=s.length();
    char* array=new char(num);
    for(long long i=0;i<num;i++)
	{
		array[i]=s.at(i);
		if(array[i]=='1') total+=a1;
		if(array[i]=='2') total+=a2;
		if(array[i]=='3') total+=a3;
		if(array[i]=='4') total+=a4;

	}
	cout<<total<<endl;
	return 0;
}


#include<string>
#include<iostream>
using namespace std;
int main()
{
	int a1,a2,a3,a4,total=0;
	string s;
	cin>>a1>>a2>>a3>>a4>>s;
    int num=s.length();
    char* array=new char(num);
    for(int i=0;i<num;i++)
	{
		array[i]=s.at(i);
		if(array[i]=='1') total+=a1;
		if(array[i]=='2') total+=a2;
		if(array[i]=='3') total+=a3;
		if(array[i]=='4') total+=a4;

	}
	cout<<total<<endl;
	return 0;
}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[4];
	static int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[4];
	static long int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	long int len = strlen(symbol);

	for (long int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000-1];
	int arr[3];
	static long calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000-1];
	int arr[3];
	static int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100];
	int arr[3];
	int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == 1)
			calories += arr[1];
		else if (symbol[i] == 2)
			calories += arr[2];
		else if (symbol[i] == 3)
			calories += arr[3];
		else if (symbol[i] == 4)
			calories += arr[4];
	}

	cout << calories;

}


#include<iostream>
using namespace std;
//#include<conio.h>
//#include<math.h>
#include<string>

void main()
{
	int arr[4],calori=0;
	string s;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> s;
	for (int b = 0; b < s.length(); b++)
	{

		if (s[b] == 0)   calori += arr[0];
	  	else if (s[b] == 1)   calori += arr[1];
		else if (s[b] == 2)   calori += arr[2];
		else if (s[b] == 3)   calori += arr[3];
	}

	cout << calori;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[3];
	static int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[3];
	static long int  calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	long int  len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[3];
	static long calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	long len = strlen(symbol);

	for (int i = 1; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[3];
	static long calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	long len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100];
	int arr[3];
	static int calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	int len = strlen(symbol);

	for (int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories+ arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories+ arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
//#include<conio.h>
using namespace std;

void main(){
	char symbol[100000];
	int arr[3];
	static long int  calories = 0;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> symbol;
	long int  len = strlen(symbol);

	for (long int i = 0; i < len; i++)
	{
		if (symbol[i] == '1')
			calories = calories + arr[0];
		else if (symbol[i] == '2')
			calories = calories + arr[1];
		else if (symbol[i] == '3')
			calories = calories + arr[2];
		else if (symbol[i] == '4')
			calories = calories + arr[3];
	}

	cout << calories;

}


#include<iostream>
using namespace std;
//#include<conio.h>
//#include<math.h>
#include<string>

void main()
{
	int arr[4];static int calori = 0;
	string s;
	for (int i = 0; i < 4; i++)
		cin >> arr[i];

	cin >> s;
	for (int b = 0; b < s.length(); b++)
	{

		if (s[b] == '1')   calori += arr[0];
		else if (s[b] == '2')   calori += arr[1];
		else if (s[b] ==  '3')   calori += arr[2];
		else if (s[b] ==  '4')   calori += arr[3];
	}

	cout << calori;

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3])
	{
		string s;
		cin>>s;
		int sum=0;
		for(int i=0;i<s.length();++i)
		{
			sum+=a[s[i]-'0'-1];
		}
		cout<<sum<<endl;
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int a[4];
	while(scanf("%d%d%d%d", &a, &a[1], &a[2], &a[3])!=EOF)
	{
		int i, total = 0;
		char s[110000];
		getchar();
		gets(s);
		for(i=0;i<strlen(s);i++)
		{
			total += a[s[i]-'0'-1];
		}
		printf("%d\n", total);
	}
}


#include <stdio.h>

int main()
{
int c,s,a[4];
	for (int i=0;i<4;++i) scanf("%d",a+i);
	getchar();
	while ((c=getchar())!=EOF) s+=a[c-'1'];
	printf("%d",s);
	return 0;
｝


#include <cstdio>

int c,s,a[4];

int main()
{
	for (int i=0;i<4;++i) scanf("%d",a+i);
	getchar();
	while ((c=getchar())!=EOF) s+=a[c-'1'];
	printf("%d",s);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <string.h>
#include<algorithm>
using namespace std;
int main()
{
    int value[4], total = 0;
    char a[200000];
    int x, y, i, j;
    scanf("%d %d %d %d", &value[0], &value[1], &value[2], &value[3]);
    getchar();
    scanf("%s", a);
    for (i = 0; i < strlen(a); i++)
    {
        if (a[i] == '1')
            total +=value[0];
        if (a[i] == '2')
            total += value[1];
        if (a[i] == '3')
            total += value[2];
        if (a[i] == '4')
            total += value[3];
    }
    printf("%d\n", total);
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    int arr[4], cont=0;
    char str[100000];
    for (int i = 0; i < 4; i++)
    {
        cin >> arr[i];
    }
    cin >> str;
    int l = strlen(str);
    for (int i = 0; i < l; i++)
    {
        if (str[i] == '1')
        {
            cont += arr[0];
        }
        else if (str[i] == '2')
        {
            cont += arr[1];
        }
        else if (str[i] == '3')
        {
            cont += arr[2];
        }
        else if (str[i] == '4')
        {
            cont += arr[3];
        }
    }
    cout << cont;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    int arr[1000], cont=0;
    char str[1000];
    for (int i = 0; i < 4; i++)
    {
        cin >> arr[i];
    }
    cin >> str;
    int l = strlen(str);
    for (int i = 0; i < l; i++)
    {
        if (str[i] == '1')
        {
            cont += arr[0];
        }
        else if (str[i] == '2')
        {
            cont += arr[1];
        }
        else if (str[i] == '3')
        {
            cont += arr[2];
        }
        else if (str[i] == '4')
        {
            cont += arr[3];
        }
    }
    cout << cont;
    return 0;
}


    #pragma comment (linker, "/STACK:200000000")
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <vector>
    #include <bitset>
    #include <math.h>
    #define pb push_back
    #define eps 1e-9
    using namespace std;

    struct coord { double x,y;};
    coord t[8];

    bool cmp1(coord a,coord b) {
            if (a.x<b.x) return true;
             else if (a.x>b.x) return false;
            return a.y<b.y;
    }

    bool cmp2(coord a,coord b) {
            return atan2(a.y,a.x)<atan2(b.y,b.x);
    }

    double len(coord a,coord b) {
            return sqrt( (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) );
    }

    bool ok(double a,double b) {
            if (fabs(a-b)<eps) return true;
            return false;
    }

    bool sqr(int i,int j,int k,int z) {
            coord g[4];
            g[0]=t[i]; g[1]=t[j]; g[2]=t[k]; g[3]=t[z];
            sort(g,g+4,cmp1);
            for (int i=1;i<4;i++) g[i].x-=g[0].x,g[i].y-=g[0].y;
            g[0].x=g[0].y=0;
            sort(g+1,g+4,cmp2);
            if (!( ok(len(g[0],g[1]),len(g[1],g[2])) && ok(len(g[1],g[2]),len(g[2],g[3])) && ok(len(g[2],g[3]),len(g[3],g[9])) ))
                    return false;
            if ( ok(g[1].x*g[3].x+g[1].y*g[3].y,0) ) return true; else return false;
            for (int i=0;i<4;i++) cout<<g[i].x<<" "<<g[i].y<<endl;
    }

    bool pu (int i,int j,int k,int z) {
            coord g[4];
            g[0]=t[i]; g[1]=t[j]; g[2]=t[k]; g[3]=t[z];
            sort(g,g+4,cmp1);
            for (int i=1;i<4;i++) g[i].x-=g[0].x,g[i].y-=g[0].y;
            g[0].x=g[0].y=0;
            sort(g+1,g+4,cmp2);
            if (!( ok(len(g[0],g[1]),len(g[3],g[2])) && ok(len(g[1],g[2]),len(g[0],g[3])) ))
                    return false;
            if ( ok(g[1].x*g[3].x+g[1].y*g[3].y,0) ) return true; else return false;
            for (int i=0;i<4;i++) cout<<g[i].x<<" "<<g[i].y<<endl;
    }

    int main() {
       //freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);
        bitset <8> mask;
       for (int i=0;i<8;i++) scanf("%lf%lf",&t[i].x,&t[i].y);
       for (int i=0;i<8;i++)
               for (int j=i+1;j<8;j++)
                       for (int k=j+1;k<8;k++)
                               for (int z=k+1;z<8;z++)
                               { mask=0;
                                     mask[i]=1; mask[j]=1; mask[k]=1; mask[z]=1;
                                     vector <int> g;
                                     for (int a=0;a<8;a++)
                                             if (mask[a]==0) g.pb(a);
                                     if (sqr(i,j,k,z)&&pu(g[0],g[1],g[2],g[3]))
                                     {
                                             cout<<"YES"<<endl;
                                            cout<<i+1<<" "<<j+1<<" "<<k+1<<" "<<z+1<<endl;
                                            cout<<g[0]+1<<" "<<g[1]+1<<" "<<g[2]+1<<" "<<g[3]+1;
                                            return 0;
                                     }
                               }
        cout<<"NO";
       return 0;
    }


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;
   struct{
      int x,y;
   }a[MAX];
   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belong to the square
            else rect[rcnt++]=j;

         next=0;
         //printf("%d\n",a[wh[k]].x);
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4])
                  break;
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
   struct{
      int x,y;
   }a[MAX];
int if222()
{
   if(a[0].x!=0) return 0;
   if(a[0].y!=0) return 0;
   if(a[1].x!=1) return 0;
   if(a[1].y!=0) return 0;
   if(a[2].x!=2) return 0;
   if(a[2].y!=0) return 0;
   if(a[3].x!=1) return 0;
   if(a[3].y!=2) return 0;

   if(a[4].x!=50) return 0;
   if(a[4].y!=50) return 0;
   if(a[5].x!=50) return 0;
   if(a[5].y!=51) return 0;
   if(a[6].x!=51) return 0;
   if(a[6].y!=51) return 0;
   if(a[7].x!=51) return 0;
   if(a[7].y!=50) return 0;
   return 1;
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;

   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belongs to the square
            else rect[rcnt++]=j;

         next=0;
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(if222() &&(i==15*16))
            printf("the value of square is %c\n",square);
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4])
                  break;
            if(if222() &&(i==15*16))
               printf("but the rest was not a rectangle\n");
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,n,j,k;
   int next;
   int rcnt,cnt;
   char square;
   struct{
      int x,y;
   }a[MAX];
   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<8;i++)
      scanf("%d%d",&a[i].x,&a[i].y);
   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;
            else rect[rcnt++]=j;

         next=0;
         //printf("%d\n",a[wh[k]].x);
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4]))
               if(l[0]+l[2]==l[4])
                  break;
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
struct{
   int x,y;
}a[MAX];
int if222()
{
   if(a[0].x!=0) return 0;
   if(a[0].y!=0) return 0;
   if(a[1].x!=1) return 0;
   if(a[1].y!=0) return 0;
   if(a[2].x!=2) return 0;
   if(a[2].y!=0) return 0;
   if(a[3].x!=1) return 0;
   if(a[3].y!=2) return 0;

   if(a[4].x!=50) return 0;
   if(a[4].y!=50) return 0;
   if(a[5].x!=50) return 0;
   if(a[5].y!=51) return 0;
   if(a[6].x!=51) return 0;
   if(a[6].y!=51) return 0;
   if(a[7].x!=51) return 0;
   if(a[7].y!=50) return 0;
   return 1;
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;

   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belongs to the square
            else rect[rcnt++]=j;

         next=0;
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(if222() &&(i==15*16))
            printf("the value of square is %c\n",square);
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4]){
                  if(if222() &&(i==15*16))
                     printf("the value of square is %c before breaking. Next stop:if(square=='y')\n",square);
                  break;
               }
            if(if222() &&(i==15*16))
               printf("but the rest was not a rectangle\n");
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else {
      printf("NO\n");
      if(if222() )
         printf("the value of square is %c; i is %d\n",square,i);
   }
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
   struct{
      int x,y;
   }a[MAX];
int if222()
{
   if(a[0].x!=0) return 0;
   if(a[0].y!=0) return 0;
   if(a[1].x!=1) return 0;
   if(a[1].y!=0) return 0;
   if(a[2].x!=2) return 0;
   if(a[2].y!=0) return 0;
   if(a[3].x!=1) return 0;
   if(a[3].y!=2) return 0;

   if(a[4].x!=50) return 0;
   if(a[4].y!=50) return 0;
   if(a[5].x!=50) return 0;
   if(a[5].y!=51) return 0;
   if(a[6].x!=51) return 0;
   if(a[6].y!=51) return 0;
   if(a[7].x!=51) return 0;
   if(a[7].y!=50) return 0;
   return 1;
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;

   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belongs to the square
            else rect[rcnt++]=j;

         next=0;
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(if222() &&(i==15*16))
            printf("the value of square is %c\n",square);
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4]){
                  if(if222() &&(i==15*16))
                     printf("the value of square is %c before breaking. Next stop:if(square=='y')\n",square);
                  break;
               }
            if(if222() &&(i==15*16))
               printf("but the rest was not a rectangle\n");
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))

#define line(i,j,k,l) ((a[i].x-a[j].x)*(a[k].y-a[l].y))
#define expand(p,i,j,k) line(p[k],p[i],p[j],p[i])
#define check(p,i,j,k) (expand(p,i,j,k)==expand(p,i,k,j))

struct{
   int x,y;
}a[MAX];
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
int col(int i,int *p)
{
   if(check(p,0,1,2))
      return 1;
   if(check(p,0,1,3))
      return 1;
   if(check(p,0,3,2))
      return 1;
   if(check(p,3,1,2))
      return 1;
/*   if(i==16*15)
      printf("eoig jfire %d\n",check(p,0,1,2));
      */
   return 0;
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}

int main()
{
   int i,n,j,k;
   int next;
   int rcnt,cnt;
   char square;
   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<8;i++)
      scanf("%d%d",&a[i].x,&a[i].y);
   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;
            else rect[rcnt++]=j;

         next=0;
         //printf("%d\n",a[wh[k]].x);
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4]))
            if(l[0]+l[1]==l[4])
               if(col(i,wh)==0)
                  square='y';
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4]))
               if(l[0]+l[2]==l[4])
                  if(col(i,rect)==0)
                     break;
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;
   struct{
      int x,y;
   }a[MAX];
   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belong to the square
            else rect[rcnt++]=j;

         next=0;
         //printf("%d\n",a[wh[k]].x);
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4])
                  break;
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 8
#define length(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
int cmp(int *a, int *b)
{
   return ((*a)-(*b));
}
   struct{
      int x,y;
   }a[MAX];
int if222()
{
   if(a[0].x!=0) return 0;
   if(a[0].y!=0) return 0;
   if(a[1].x!=1) return 0;
   if(a[1].y!=0) return 0;
   if(a[2].x!=2) return 0;
   if(a[2].y!=0) return 0;
   if(a[3].x!=1) return 0;
   if(a[3].y!=2) return 0;

   if(a[4].x!=50) return 0;
   if(a[4].y!=50) return 0;
   if(a[5].x!=50) return 0;
   if(a[5].y!=51) return 0;
   if(a[6].x!=51) return 0;
   if(a[6].y!=51) return 0;
   if(a[7].x!=51) return 0;
   if(a[7].y!=50) return 0;
   return 1;
}
int bits(int a)
{
   int ans=0;
   while(a){
      if(a&1)
         ans++;
      a>>=1;
   }
   return ans;
}
int main()
{
   int i,j,k;
   int next;
   int rcnt,cnt;
   char square;

   int l[MAX],wh[MAX],rect[MAX];

   for(i=0;i<MAX;i++)
      scanf("%d%d",&a[i].x,&a[i].y);

   for(i=0;i<(1<<MAX);i++){
      square='n';
      if(bits(i)==4){
         rcnt=cnt=0;
         for(j=0;j<MAX;j++)
            if(i&(1<<j))
               wh[cnt++]=j;//belongs to the square
            else rect[rcnt++]=j;

         next=0;
         for(j=0;j<4;j++)
            for(k=j+1;k<4;k++)
               l[next++]=length(a[wh[k]],a[wh[j]]);

         qsort(l,6,sizeof(int),cmp);

         if((l[0]==l[1])&&(l[1]==l[2])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
            if(l[0]+l[1]==l[4])
               square='y';
         if(if222() &&(i==15*16))
            printf("the value of square is %c\n",square);
         if(square=='y'){
            next=0;
            for(j=0;j<4;j++)
               for(k=j+1;k<4;k++)
                  l[next++]=length(a[rect[k]],a[rect[j]]);

            qsort(l,6,sizeof(int),cmp);

            if((l[0]==l[1])&&(l[2]==l[3])&&(l[3]!=l[4])&&(l[4]==l[5]))
               if(l[0]+l[2]==l[4]){
                  printf("the value of square is %c before breaking. Next stop:if(square=='y')\n",square);
                  break;
               }
            if(if222() &&(i==15*16))
               printf("but the rest was not a rectangle\n");
            square='n';
         }
      }
      square='n';
   }
   if(square=='y'){
      printf("YES\n");
      for(i=0;i<4;i++)
         printf("%d ",1+wh[i]);
      printf("\n");
      for(i=0;i<4;i++)
         printf("%d ",1+rect[i]);
      printf("\n");
   }
   else printf("NO\n");
   return 0;
}


#include <stdio.h>

int ok = 0, sol[8];

typedef struct po {
   int x, y;
} point;

point tab[8];

int prp(b,a,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double a1, a2;
   if (xa != xb && xa != xc)
   {
      a1 = ((double) ya-yb)/((double) xa-xb);
      a2 = ((double) ya-yc)/((double) xa-xc);
      if (a1*a2 + 1.0 < 0.0000001 && a1*a2 + 1.0 > -0.0000001)
         return 1;
      else
         return 0;
   }
   if (xa == xb && ya == yc)
      return 1;
   if (xa == xc && ya == yb)
      return 1;
   return 0;
}

int rect(int a[4])
{
   if (prp(a[0], a[1], a[2]) && prp(a[1], a[2], a[3]) && prp(a[2], a[3], a[0]) && prp(a[3], a[0], a[1]) ||
       prp(a[0], a[1], a[3]) && prp(a[1], a[3], a[2]) && prp(a[3], a[2], a[0]) && prp(a[2], a[0], a[1]) ||
       prp(a[2], a[1], a[3]) && prp(a[1], a[3], a[0]) && prp(a[3], a[0], a[2]) && prp(a[0], a[2], a[1]))
      return 1;
   else
      return 0;
}

int len(a,b,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double lab = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
   double lac = (xa-xc)*(xa-xc)+(ya-yc)*(ya-yc);
   double lbc = (xb-xc)*(xb-xc)+(yb-yc)*(yb-yc);
   if (lab - lac < 0.0000001 && lac - lab < 0.0000001)
      return 1;
   if (lbc - lac < 0.0000001 && lac - lbc < 0.0000001)
      return 1;
   if (lbc - lab < 0.0000001 && lab - lbc < 0.0000001)
      return 1;
   return 0;
}

int sq(int a[4])
{
   if (len(a[0], a[1], a[2]) && len(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

void test(int a[4])
{
   if (ok)
      return;
   int i, j, k=0;
   if (rect(a))
      if (sq(a))
      {
         int b[4];
         for (i=0; i<8; i++)
         {
            int to = 1;
            for (j=0; j<4; j++)
               if (i == a[j])
                  to = 0;
            if (to)
               b[k++] = i;
         }
         if (rect(b))
         {
            ok = 1;
            for (i=0; i<4; i++)
            {
               sol[i] = a[i];
               sol[i+4] = b[i];
            }
         }
      }
   return;
}

int main(void)
{
   int i, j, k, l;
   for (i=0; i<8; i++)
      scanf("%d %d", &tab[i].x, &tab[i].y);
   for (i=0; i<5; i++)
      for (j=i+1; j<6; j++)
         for (k=j+1; k<7; k++)
            for (l=k+1; l<8; l++)
            {
               int s[4] = {i,j,k,l};
               test(s);
            }
   if (ok)
   {
      printf("YES\n");
      for (i=0; i<8; i++)
         printf("%d%c", sol[i]+1, i%4 != 3 ? ' ' : '\n');
   }
   else
      printf("NO\n");
   return 0;
}


#include <stdio.h>

int ok = 0, sol[8];

typedef struct po {
   int x, y;
} point;

point tab[8];

int prp(a,b,c)
{
   if (a == 2 && b == 3 && c == 4)
      a = 2;
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double a1, a2;
   if (xa != xb && xa != xc)
   {
      a1 = ((double) ya-yb)/((double) xa-xb);
      a2 = ((double) ya-yc)/((double) xa-xc);
      if (a1*a2 + 1.0 < 0.0000001 && a1*a2 + 1.0 > -0.0000001)
         return 1;
      else
         return 0;
   }
   if (xa == xb && ya == yc)
      return 1;
   if (xa == xc && ya == yb)
      return 1;
   return 0;
}

int pr(a,b,c)
{
   if (prp(a,b,c) || prp(b,a,c) || prp(c,b,a))
      return 1;
   else
      return 0;
}

int rect(int a[4])
{
   if (pr(a[0], a[1], a[2]) && pr(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

int len(a,b,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double lab = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
   double lac = (xa-xc)*(xa-xc)+(ya-yc)*(ya-yc);
   double lbc = (xb-xc)*(xb-xc)+(yb-yc)*(yb-yc);
   if (lab - lac < 0.0000001 && lac - lab < 0.0000001)
      return 1;
   if (lbc - lac < 0.0000001 && lac - lbc < 0.0000001)
      return 1;
   if (lbc - lab < 0.0000001 && lab - lbc < 0.0000001)
      return 1;
   return 0;
}

int sq(int a[4])
{
   if (len(a[0], a[1], a[2]) && len(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

void test(int a[4])
{
   if (ok)
      return;
   int i, j, k=0;
   if (rect(a))
      if (sq(a))
      {
         int b[4];
         for (i=0; i<8; i++)
         {
            int to = 1;
            for (j=0; j<4; j++)
               if (i == a[j])
                  to = 0;
            if (to)
               b[k++] = i;
         }
         if (rect(b))
         {
            ok = 1;
            for (i=0; i<4; i++)
            {
               sol[i] = a[i];
               sol[i+4] = b[i];
            }
         }
      }
   return;
}

int main(void)
{
   int i, j, k, l;
   for (i=0; i<8; i++)
      scanf("%d %d", &tab[i].x, &tab[i].y);
   for (i=0; i<5; i++)
      for (j=i+1; j<6; j++)
         for (k=j+1; k<7; k++)
            for (l=k+1; l<8; l++)
            {
               int s[4] = {i,j,k,l};
               test(s);
            }
   if (ok)
   {
      printf("YES\n");
      for (i=0; i<8; i++)
         printf("%d%c", sol[i]+1, i%4 != 3 ? ' ' : '\n');
   }
   else
      printf("NO\n");
   return 0;
}


#include <stdio.h>

int ok = 0, sol[8];

typedef struct po {
   int x, y;
} point;

point tab[8];

int prp(b,a,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double a1, a2;
   if (xa != xb && xa != xc)
   {
      a1 = ((double) ya-yb)/((double) xa-xb);
      a2 = ((double) ya-yc)/((double) xa-xc);
      if (a1*a2 + 1.0 < 0.0000001 && a1*a2 + 1.0 > -0.0000001)
         return 1;
      else
         return 0;
   }
   if (xa == xb && ya == yc)
      return 1;
   if (xa == xc && ya == yb)
      return 1;
   return 0;
}

int rect(int a[4])
{
   if (prp(a[0], a[1], a[2]) && prp(a[1], a[2], a[3]) && prp(a[2], a[3], a[0]) && prp(a[3], a[0], a[1]) ||
       prp(a[0], a[1], a[3]) && prp(a[1], a[3], a[2]) && prp(a[3], a[2], a[0]) && prp(a[2], a[0], a[1]))
      return 1;
   else
      return 0;
}

int len(a,b,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double lab = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
   double lac = (xa-xc)*(xa-xc)+(ya-yc)*(ya-yc);
   double lbc = (xb-xc)*(xb-xc)+(yb-yc)*(yb-yc);
   if (lab - lac < 0.0000001 && lac - lab < 0.0000001)
      return 1;
   if (lbc - lac < 0.0000001 && lac - lbc < 0.0000001)
      return 1;
   if (lbc - lab < 0.0000001 && lab - lbc < 0.0000001)
      return 1;
   return 0;
}

int sq(int a[4])
{
   if (len(a[0], a[1], a[2]) && len(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

void test(int a[4])
{
   if (ok)
      return;
   int i, j, k=0;
   if (rect(a))
      if (sq(a))
      {
         int b[4];
         for (i=0; i<8; i++)
         {
            int to = 1;
            for (j=0; j<4; j++)
               if (i == a[j])
                  to = 0;
            if (to)
               b[k++] = i;
         }
         if (rect(b))
         {
            ok = 1;
            for (i=0; i<4; i++)
            {
               sol[i] = a[i];
               sol[i+4] = b[i];
            }
         }
      }
   return;
}

int main(void)
{
   int i, j, k, l;
   for (i=0; i<8; i++)
      scanf("%d %d", &tab[i].x, &tab[i].y);
   for (i=0; i<5; i++)
      for (j=i+1; j<6; j++)
         for (k=j+1; k<7; k++)
            for (l=k+1; l<8; l++)
            {
               int s[4] = {i,j,k,l};
               test(s);
            }
   if (ok)
   {
      printf("YES\n");
      for (i=0; i<8; i++)
         printf("%d%c", sol[i]+1, i%4 != 3 ? ' ' : '\n');
   }
   else
      printf("NO\n");
   return 0;
}


#include <stdio.h>

int ok = 0, sol[8];

typedef struct po {
   int x, y;
} point;

point tab[8];

int prp(a,b,c)
{
   if (a == 1 && b == 2 && c == 3)
      a = 1;
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double a1, a2;
   if (xa != xb && xa != xc)
   {
      a1 = (ya-yb)/(xa-xb);
      a2 = (ya-yc)/(xa-xc);
      if (a1*a2 + 1.0 < 0.0000001 && a1*a2 + 1.0 > -0.0000001)
         return 1;
      else
         return 0;
   }
   if (xa == xb && ya == yc)
      return 1;
   if (xa == xc && ya == yb)
      return 1;
   return 0;
}

int pr(a,b,c)
{
   if (prp(a,b,c) || prp(b,a,c) || prp(c,b,a))
      return 1;
   else
      return 0;
}

int rect(int a[4])
{
   if (pr(a[0], a[1], a[2]) && pr(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

int len(a,b,c)
{
   int xa = tab[a].x, ya = tab[a].y;
   int xb = tab[b].x, yb = tab[b].y;
   int xc = tab[c].x, yc = tab[c].y;
   double lab = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
   double lac = (xa-xc)*(xa-xc)+(ya-yc)*(ya-yc);
   double lbc = (xb-xc)*(xb-xc)+(yb-yc)*(yb-yc);
   if (lab - lac < 0.0000001 && lac - lab < 0.0000001)
      return 1;
   if (lbc - lac < 0.0000001 && lac - lbc < 0.0000001)
      return 1;
   if (lbc - lab < 0.0000001 && lab - lbc < 0.0000001)
      return 1;
   return 0;
}

int sq(int a[4])
{
   if (len(a[0], a[1], a[2]) && len(a[1], a[2], a[3]))
      return 1;
   else
      return 0;
}

void test(int a[4])
{
   if (ok)
      return;
   int i, j, k=0;
   if (rect(a))
      if (sq(a))
      {
         int b[4];
         for (i=0; i<8; i++)
         {
            int to = 1;
            for (j=0; j<4; j++)
               if (i == a[j])
                  to = 0;
            if (to)
               b[k++] = i;
         }
         if (rect(b))
         {
            ok = 1;
            for (i=0; i<4; i++)
            {
               sol[i] = a[i];
               sol[i+4] = b[i];
            }
         }
      }
   return;
}

int main(void)
{
   int i, j, k, l;
   for (i=0; i<8; i++)
      scanf("%d %d", &tab[i].x, &tab[i].y);
   for (i=0; i<5; i++)
      for (j=i+1; j<6; j++)
         for (k=j+1; k<7; k++)
            for (l=k+1; l<8; l++)
            {
               int s[4] = {i,j,k,l};
               test(s);
            }
   if (ok)
   {
      printf("YES\n");
      for (i=0; i<8; i++)
         printf("%d%c", sol[i]+1, i%4 != 3 ? ' ' : '\n');
   }
   else
      printf("NO\n");
   return 0;
}


#include <stdio.h>
#include <stdlib.h>
int x[8], y[8];
int length (int p, int q)
{
	return (x[p] - x[q]) * (x[p] - x[q]) + (y[p] - y[q]) * (y[p] - y[q]);
}
int diamond (int a, int b, int c, int d)
{
	if (length (a, b) == length (a, c) || length (a, b) == length (a, d) || length (a, d) == length (a, c) )
		return 1;
	return 0;
}
int rectangle (int a, int b, int c, int d)
{
	if (length (a, b) == length (d, c) && length (d, b) == length (a, c) && length (a, d) == length (b, c) )
		return 1;
	return 0;
}
int main (void)
{
	int i, j, a, b, c, d, other[4];
	for (i = 0; i < 8; i++)
		scanf ("%d%d", &x[i], &y[i]);
	for (a = 0; a < 5; a++)
		for (b = a+1; b < 6; b++)
			for (c = b+1; c < 7; c++)
				for (d = c+1; d < 8; d++)
				{
					j = 0;
					for (i = 0; j < 4; i++)
						if (i != a && i != b && i != c && i != d)
							other[j++] = i;
					if (diamond (a, b, c, d) == 1 && rectangle (a, b, c, d) == 1 && rectangle (other[0], other[1], other[2], other[3]) == 1)
					{
						printf ("YES\n%d %d %d %d\n%d %d %d %d\n", a+1, b+1, c+1, d+1, other[0]+1, other[1]+1, other[2]+1, other[3]+1);
						exit (0);
					}
				}
	printf ("NO\n");
	return 0;
}


import java.util.*;
import java.io.*;
public class a {
    static long mod = 1000000009;
    static char[][] res;
public static void main(String[] args) throws IOException
{
    //Scanner input = new Scanner(new File("input.txt"));
    //PrintWriter out = new PrintWriter(new File("output.txt"));
  input.init(System.in);
  PrintWriter out  = new PrintWriter((System.out));
  xs = new int[8]; ys = new int[8];
  String[] orders = {"0123","0132","0213","0231","0312","0321",
          "1023","1032","1203","1230","1302","1320",
          "2013","2031","2103","2130","2301","2310",
          "3012","3021","3102","3120","3201","3210"};
  for(int i = 0; i<8; i++)
  {
      xs[i] = input.nextInt();
      ys[i] = input.nextInt();
  }
  boolean found = false;
  for(int i = 0; i<8; i++)
      for(int j = 0; j<8; j++)
          for(int k = 0; k<8; k++)
              for(int l = 0; l<8; l++)
              {
                  if(i==j||i==k||i==l||j==k||j==l||k==l) continue;
                  int[] first = {i,j,k,l};
                  ArrayList<Integer> secondlist = new ArrayList<Integer>();
                  for(int m = 0; m<8; m++)
                      if(m != i && m != j && m != k && m != l) secondlist.add(m);
                  int[] second = new int[4];
                  for(int m = 0; m<4; m++)
                  {
                      second[m] = secondlist.get(m);
                  }
                  for(int x = 0; x<24; x++)
                  {
                      if(found) break;
                      for(int y = 0; y<24; y++)
                      {
                          int[] sortedx = new int[4];
                          for(int z = 0; z<4; z++)
                              sortedx[z] = first[orders[x].charAt(z)-'0'];
                          int[] sortedy = new int[4];
                          for(int z = 0; z<4; z++)
                              sortedy[z] = second[orders[y].charAt(z)-'0'];
                          int dist = dist(sortedx[0], sortedx[1]);
                          if(dist != dist(sortedx[1], sortedx[2])) continue;
                          if(dist != dist(sortedx[3], sortedx[2])) continue;
                          if(dist != dist(sortedx[0], sortedx[3])) continue;
                          if(dist + dist != dist(sortedx[0], sortedx[2])) continue;
                          int dist1 = dist(sortedy[0], sortedy[1]), dist2 = dist(sortedy[2], sortedy[1]);
                          if(dist1 != dist(sortedy[2], sortedy[3])) continue;
                          if(dist2 != dist(sortedy[3], sortedy[0])) continue;
                          if(dist1+dist2 != dist(sortedy[0], sortedy[2])) continue;
                          found = true;
                          out.println("YES");
                          for(int xx: sortedx) out.print((xx+1)+" ");
                          out.println();
                          for(int yy: sortedy) out.print((yy+1)+" ");
                          break;
                      }
                      if(found) break;
                  }
                  if(found) break;
              }
  if(!found) out.println("NO");
  out.close();
}
static int[] xs, ys;
static int dist(int a, int b)
{
    return (xs[a]-xs[b])*(xs[a]-xs[b]) + (ys[a]-ys[b])*(ys[a]-ys[b]);
}
static long pow(long x, long p)
{
    if(p==0) return 1;
    if((p&1) > 0)
    {
        return (x*pow(x, p-1))%mod;
    }
    long sqrt = pow(x, p/2);
    return (sqrt*sqrt)%mod;
}
static long gcd(long a, long b)
{
    if(b==0) return a;
    return gcd(b, a%b);
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static long nextLong() throws IOException {
      return Long.parseLong( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
/*
Sum Interval Tree - uses O(n) space
Updates and queries over a range of values in log(n) time
Note: If querying all elements, use difference array instead.
*/
static class IT
{
    int[] left,right, val, a, b;
    IT(int n)
    {
        left = new int[4*n];
        right = new int[4*n];
        val = new int[4*n];
        a = new int[4*n];
        b = new int[4*n];
        init(0,0, n);
    }
    int init(int at, int l, int r)
    {
        a[at] = l;
        b[at] = r;
        if(l==r)
            left[at] = right [at] = -1;
        else
        {
            int mid = (l+r)/2;
            left[at] = init(2*at+1,l,mid);
            right[at] = init(2*at+2,mid+1,r);
        }
        return at++;
    }
    //return the sum over [x,y]
    int get(int x, int y)
    {
        return go(x,y, 0);
    }
    int go(int x,int y, int at)
    {
        if(at==-1) return 0;
        if(x <= a[at] && y>= b[at]) return val[at];
        if(y<a[at] || x>b[at]) return 0;
        return go(x, y, left[at]) + go(x, y, right[at]);
    }
    //add v to elements x through y
    void add(int x, int y, int v)
    {
        go3(x, y, v, 0);
    }
    void go3(int x, int y, int v, int at)
    {
        if(at==-1) return;
        if(y < a[at] || x > b[at]) return;
        val[at] += (Math.min(b[at], y) - Math.max(a[at], x) + 1)*v;
        go3(x, y, v, left[at]);
        go3(x, y, v, right[at]);
    }
}
}


import java.util.*;
import java.io.*;

public class Main implements Runnable {
	class Point{
                int x, y;
                Point(int x, int y){
                        this.x = x;
                        this.y = y;
                }
        }
        private int d(Point a, Point b){
                return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        }

        private boolean sq(Point a, Point b, Point c, Point d){
                if(d(a, b) == d(b, c) && d(b, c) == d(c, d) && d(c, d) == d(d, a)) return true;
                return false;
        }

        private boolean rec(Point a, Point b, Point c, Point d){
                if(d(a,b) == d(c, d) && d(a, d) == d(b, c)) return true;
                return false;
        }

        private boolean check(){
                if(sq(p[a[0]], p[a[1]], p[a[2]], p[a[3]]) && rec(p[a[4]], p[a[5]], p[a[6]], p[a[7]])) return true;
                return false;
        }

        Point[] p;
        int[] a;
        int N = 8;
	public void solve() throws IOException {
               p = new Point[8];
               for(int i = 0; i < 8; i++){
                       p[i]  = new Point(nextInt(), nextInt());
               }

               a = new int[N];
               for(int i = 0; i < N; i++) a[i] = i;

               boolean ok = false;
               do{
                       //out.println(a[0] + " " + a[1] + " " + a[2] + " " + a[3] + " " + a[4] + " " + a[5] + " " + a[6] + " " + a[7]);
                       if(check()){
                               ok = true;
                               break;
                       }
               }while(nextPermutation());

               if(ok){
                       out.println("YES");
                       out.println((a[0] + 1) + " " + (a[1] + 1) + " " + (a[2] + 1) + " " + (a[3] + 1));
                       out.println((a[4] + 1) + " " + (a[5] + 1) + " " + (a[6] + 1) + " " + (a[7] + 1));
               }
               else{
                       out.println("NO");
               }
	}

	private boolean nextPermutation(){
                int i = N-2;
                while(i >= 0  && a[i] >= a[i+1]) i--;
                if(i < 0) return false;

                int j = N-1;
                while(a[i] >= a[j]) j--;

                int t = a[i];
                a[i] = a[j];
                a[j] =t;

                i++;
                j = N-1;
                while(i < j){
                        t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                        i++;
                        j--;
                }
                return true;
        }

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}


import java.util.*;
import java.io.*;

public class Main implements Runnable {
	class Point{
                int x, y;
                Point(int x, int y){
                        this.x = x;
                        this.y = y;
                }
        }
        private int d(Point a, Point b){
                return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        }

        private int dot(Point aa, Point bb, Point cc){
                Point a = new Point(bb.x - aa.x, bb.y - aa.y);
                Point b = new Point(cc.x - aa.x, cc.y - aa.y);

                return (a.x - b.x) * (a.y - b.y);
        }
        private boolean goodAngle(Point a, Point b, Point c,  Point d){
                if(dot(a, b, c) == 0 && dot(b, c, d) == 0 && dot(c, d, a) == 0&& dot(d, a, b) == 0)return true;
                return false;
        }
        private boolean sq(Point a, Point b, Point c, Point d){
                //angle must be 90 degree
                int l = d(a, b);
                if(l != d(b, c) || l != d(c, d) || l != d(a, d) && !goodAngle(a, b, c, d)) return false;

                return true;
        }

        private boolean rec(Point a, Point b, Point c, Point d){
                if(d(a,b) == d(c, d) && d(a, d) == d(b, c) && (long)d(a,b) * (long)d(a, d) > 0 && goodAngle(a, b, c, d)) return true;
                return false;
        }

        private boolean check(){
                if(sq(p[a[0]], p[a[1]], p[a[2]], p[a[3]]) && rec(p[a[4]], p[a[5]], p[a[6]], p[a[7]])) return true;
                return false;
        }

        Point[] p;
        int[] a;
        int N = 8;
	public void solve() throws IOException {
               p = new Point[8];
               for(int i = 0; i < 8; i++){
                       p[i]  = new Point(nextInt(), nextInt());
               }

               a = new int[N];
               for(int i = 0; i < N; i++) a[i] = i;

               boolean ok = false;
               do{
                       //out.println(a[0] + " " + a[1] + " " + a[2] + " " + a[3] + " " + a[4] + " " + a[5] + " " + a[6] + " " + a[7]);
                       if(check()){
                               ok = true;
                               break;
                       }
               }while(nextPermutation());

               if(ok){
                       out.println("YES");
                       out.println((a[0] + 1) + " " + (a[1] + 1) + " " + (a[2] + 1) + " " + (a[3] + 1));
                       out.println((a[4] + 1) + " " + (a[5] + 1) + " " + (a[6] + 1) + " " + (a[7] + 1));
               }
               else{
                       out.println("NO");
               }
	}

	private boolean nextPermutation(){
                int i = N-2;
                while(i >= 0  && a[i] >= a[i+1]) i--;
                if(i < 0) return false;

                int j = N-1;
                while(a[i] >= a[j]) j--;

                int t = a[i];
                a[i] = a[j];
                a[j] =t;

                i++;
                j = N-1;
                while(i < j){
                        t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                        i++;
                        j--;
                }
                return true;
        }

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}


import java.util.*;
import java.io.*;

public class Main implements Runnable {
	class Point{
                int x, y;
                Point(int x, int y){
                        this.x = x;
                        this.y = y;
                }
        }
        private int d(Point a, Point b){
                return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        }

        private int dot(Point a, Point b, Point c){
            int vx0 = a.x - b.x;
            int vy0 = a.y - b.y;
            int vx1 = c.x - b.x;
            int vy1 = c.y - b.y;
            int ret = (vx0 * vx1 + vy0 * vy1);
            return ret;
        }

        private boolean goodAngle(Point a, Point b, Point c,  Point d){
                if(dot(a, b, c) == 0 && dot(b, c, d) == 0 && dot(c, d, a) == 0&& dot(d, a, b) == 0)return true;
                return false;
        }
        private boolean sq(Point a, Point b, Point c, Point d){
                //angle must be 90 degree
                int l = d(a, b);
                if(l == d(b, c) && l == d(c, d) && l == d(a, d) && goodAngle(a, b, c, d)) return true;

                return false;
        }

        private boolean rec(Point a, Point b, Point c, Point d){
                //angle must be 90 degree
                if(d(a,b) == d(c, d) && d(a, d) == d(b, c) && goodAngle(a, b, c, d)) return true;
                return false;
        }

        private boolean check(){
                if(sq(p[a[0]], p[a[1]], p[a[2]], p[a[3]]) && rec(p[a[4]], p[a[5]], p[a[6]], p[a[7]])) return true;
                return false;
        }

        Point[] p;
        int[] a;
        int N = 8;
	public void solve() throws IOException {
               p = new Point[8];
               for(int i = 0; i < 8; i++){
                       p[i]  = new Point(nextInt(), nextInt());
               }

               a = new int[N];
               for(int i = 0; i < N; i++) a[i] = i;

               boolean ok = false;
               do{
                       //out.println(a[0] + " " + a[1] + " " + a[2] + " " + a[3] + " " + a[4] + " " + a[5] + " " + a[6] + " " + a[7]);
                       if(check()){
                               ok = true;
                               break;
                       }
               }while(nextPermutation());

               if(ok){
                       out.println("YES");
                       out.println((a[0] + 1) + " " + (a[1] + 1) + " " + (a[2] + 1) + " " + (a[3] + 1));
                       out.println((a[4] + 1) + " " + (a[5] + 1) + " " + (a[6] + 1) + " " + (a[7] + 1));
               }
               else{
                       out.println("NO");
               }
	}

	private boolean nextPermutation(){
                int i = N-2;
                while(i >= 0  && a[i] >= a[i+1]) i--;
                if(i < 0) return false;

                int j = N-1;
                while(a[i] >= a[j]) j--;

                int t = a[i];
                a[i] = a[j];
                a[j] =t;

                i++;
                j = N-1;
                while(i < j){
                        t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                        i++;
                        j--;
                }
                return true;
        }

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists())
                System.setIn(new FileInputStream("input.txt"));
        } catch (SecurityException e) {
        }
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    private void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    class Point implements Comparable<Point>{
        long x,y;

        public Point(long x, long y) {
            super();
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Point o) {
            if (x != o.x)
                return Long.compare(x, o.x);
            return Long.compare(y, o.y);
        }
    }

    long scalarMul(Point middle, Point a, Point b) {
        return (a.x - middle.x) * (b.x - middle.x) + (a.y - middle.y) * (b.y - middle.y);
    }

    boolean isRectangle(Point[] point) {
        sort(point);
        return (scalarMul(point[0], point[1], point[2]) == 0) && (scalarMul (point[3], point[1], point[2]) == 0);
    }

    boolean isSquare(Point[] point) {
        return isRectangle(point) && (point[3].x - point[1].x == point[1].y - point[0].y);
    }

    Point[] point = new Point[8];

    int[] squareIndex = new int[4];
    int[] rectangleIndex = new int[4];

    Point[] square = new Point[4];
    Point[] rectangle = new Point[4];

    boolean[] used = new boolean[8];
    boolean dfs (int p) {
        if(p == 4) {
            int k = 0;
            for(int i = 0; i < 8; i++) {
                boolean existIndex = false;
                for(int j = 0; j < 4; j++) {
                    if(i == squareIndex[j])
                        existIndex = true;
                }
                if(!existIndex) {
                    rectangleIndex[k++] = i;
                }
            }

            for(int i = 0; i < 4; i++)
                square[i] = point[squareIndex[i]];
            for(int i = 0; i < 4; i++)
                rectangle[i] = point[rectangleIndex[i]];

//          System.err.println("Sq: " + Arrays.toString(squareIndex) + " " + isSquare(square));
//          System.err.println("Re: " + Arrays.toString(rectangleIndex) + " " + isRectangle(rectangle));

            if(isRectangle(rectangle) && isSquare(square))
                return true;
        } else {
            for(int i = 0; i < 8; i++) {
                if(!used[i]) {
                    used[i] = true;
                    squareIndex[p] = i;
                    if ( dfs( p + 1 ) )
                        return true;
                    used[i] = false;
                }
            }
        }
        return false;
    }

    private void solve() throws IOException {
        for(int i = 0; i < 8; i++) {
            point[i] = new Point(nextInt(), nextInt());
        }

//      Point[] p = new Point[4];
//      for(int i = 0; i < 4; i++)
//          p[i] = point[i];
//      sort(p);
//      for(int i = 0; i < 4; i++) {
//          out.println(p[i].x + " " + p[i].y);
//      }
//      System.err.println(isSquare(p));

        if(dfs(0)) {
            out.println("YES");
            for(int i = 0; i < 4; i++)
                out.print((squareIndex[i] + 1) + " ");
            out.println();
            for(int i = 0; i < 4; i++)
                out.print((rectangleIndex[i] + 1) + " ");
            out.println();
        } else {
            out.println("NO");
        }
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }
    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }
}