#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#define BASE 163
#define MOD 1000000007
using namespace std;

int main() 
{
	long long pow[10], a = 1;
	for (int i = 1; i < 10; ++i)
	{
		a *= BASE;
		pow[i] = a % MOD;
	}
	pow[0] = 1;
	long long hash[10];
	memset (hash, 0, sizeof(hash));
	string s = "abcdab";
	for (int i = s.size()-1; i >= 0; --i)
	{
		if (i < s.size()-1)
			hash[i] = (hash[i+1] * BASE) % MOD;
		hash[i] += s[i];
		hash[i] %= MOD;
	}
	for (int i = 0; i < s.size(); ++i)
		printf ("%d\n", hash[i]);
	printf ("Hash of 'abc' is %d\n", hash[0] - ((hash[3] * pow[strlen("abc")]) % MOD));	
	return 0;
}