Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n, divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively on the figure:    To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely many cookies of size 2 and larger, and there are no cookies of size 1, therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.

The first line contains a single integer n (0 ≤ n ≤ 1000).

Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.

NoteIf the box possesses the base of 23 × 23 (as in the example), then the cookies will be put there in the following manner:

#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int mod=10e6+3;
int n;
int sum=1;
int main()
{
	//freopen("cookies.in","r",stdin);
	//freopen("cookies.out","w",stdout);
	scanf("%d",&n);sum=1;
	for(int i=1;i<=n-1;i++)
	sum*=3,sum%=1000003;
	cout<<sum;
}

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#define M_PI    3.14159265358979323846  /* pi */
#define ri(i) int i;cin>>i;
#define rii(i,j) int i,j;cin>>i>>j;
#define riii(i,j,k) int i,j,k;cin>>i>>j>>k;
#define rc(i) char i;cin>>i;
#define rll(i) long long i;cin>>i;
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fff(i,s,n) for(i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n-1);i>=(s);i--)
#define frf(i,s,n) for(i=(n-1);i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define FFf(i,s,n) for(i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define Frf(i,s,n) for(i=(n);i>=(s);i--)
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()

template<typename T, typename U> inline void swap(T &a, U &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

inline void swap(int &a, int &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

inline void swap(long long &a, long long &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

template<typename T, typename U> inline void smax(T &a, U b) {
    if (b > a)a = b;
}

template<typename T, typename U> inline void smin(T &a, U b) {
    if (b < a)a = b;
}

inline int gcd(int a, int b) {
    if (a < b)swap(a, b);
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

long long nchose(int a, int b) {
    long long ans = 1;
    smax(a, b - a);
    int p = 2;

    FF(i, b - a + 1, b) {
        ans *= (long long) i;
        while (p <= a && ans % p == 0)ans /= p++;
    }
    return ans;
}

using namespace std;
static long long MOD = 1000003;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll > vvll;
typedef pair<vi, vi> pvi;
typedef vector<vi > vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<string, string> > vpss;
typedef vector<pii > vpii;
typedef vector<pll > vpll;
typedef vector<vpii > vvpii;
typedef map<int, int> mii;
typedef unordered_map<int, int> imap;
typedef unordered_map<ll, ll> lmap;

ll n,ans,t;

int main(){
    cin>>n;
    if(n<1){
        cout<<1;return 0;
    }
    n-=1;
    ans=1;
    while(n-->0){
        ans*=3;
        ans%=MOD;
        t%=MOD;
    }
    cout<<ans;
}

#include <iostream>

using namespace std;
const int MOD = 1000*1000+3;
int main(){
    int n,ans=1;
    cin>>n;
    for(int i=0;i<n-1;i++,ans%=MOD)
        ans*=3;
    cout<<ans;
}

#include <iostream>
using namespace std;
int n;
long long dem=1;
int main()
{
    cin>>n;
    for(int i=2; i<=n; i++)
        dem=(dem*3)%1000003;
    cout<<dem;
}

#include<iostream>
using namespace std;
int main(){
    int n=0;
    long long res=1;
    cin>>n;
    for(int i=0;i<n-1;i++){
        res=res*3%1000003;
    }
    cout<<res;
}

#include<bits/stdc++.h>

#define LL long long
#define Dl double
#define Pb push_back
#define Mp make_pair

using namespace std;

typedef vector<LL> Vl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mod 1000003

LL pw[1010];

int main()
{

    LL x = 1;
    for(LL i = 0; i < 1010; i++){
        pw[i] = x;
        x = (3 * x) % mod;
        x %= mod;
    }
    LL n;
    cin >> n;

    if(n == 0)
        return cout << 1 << '\n', 0;
    cout << pw[n - 1] << '\n';
    return 0;
}

 #include <iostream>
 using namespace std;

 int main() {
 int n,p=1;
    cin>>n;
    for(int i=0 ; i<n-1 ; i++){
        p=p*3 % 1000003;

    }
    cout<<p;
    }

#include <iostream>
#include <vector>
#include <string>
const int mod= 1e6+3;
using namespace std;
int main ()
{
int n;
cin>>n;
int ans=1;for (int i=1;i<=n-1;i++){
	ans=ans*3%mod;
}
cout<<ans;
}

#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
/*
int pot(int B,int EX){int P=1;
    if(EX==0)return 1;
    else return B*pot(B,EX-1);

}
int pmod(int b,int ex){int p=1;
    if(ex==0)return 1;
    if(ex%2==0) return p*=pot(pmod(b,ex/2),2))%1000003;
    else return p*=(b*pot(pmod(b,(ex-1)/2),2))%1000003;
}*/

int main(){
    int n;
    cin>>n;int p=1;
    //cout<<pmod(3,n-1)<<endl;
    for(int i=1;i<=n-1;++i)p=(p*3)%1000003;
    cout<<p<<endl;

}

#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
using namespace std;
int main () {
  ios::sync_with_stdio(false);
  cin.tie (0);
  int n; cin>>n;
  int start=1;
  for (ll i=1;i<n;++i) {
    start*=3;
    start%=1000003;
  }
  cout<<start;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define INPUTL(i,n) for(ll i=0 ; i<n ; i++)
const int MOD = 10 ; // 1000000009 , 1000000023 ,998244353
const ll INF = (1e18);
const ll infinity = (1e9);
const ld PI = 4*atan((ld)1);

void array_debug(vector<ll>ar){
    for(auto x: ar)cout << x << ' ';
    cout << '\n';
}
ll power(ll x,ll n,ll MOD)
{
    ll result=1;
    while(n>0){
        if(n&1)result = (result * x)%MOD;
        x=(x*x)%MOD;
        n >>= 1;
    }
    return result%MOD;
}

ll gcd(ll a , ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}

int main() {
    #ifdef AVI
        freopen("input.txt" , "r" , stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);

    ll n;
    cin >> n;
    ll res = power(3,n-1,(1e6)+3);
    cout << res;
}

/**
    In the name of Allah, the Most Gracious, the Most Merciful.
**/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 1e5 + 5;
const int M = 1e6 + 3;

int ara[N];

int main() {
        #ifdef _OFFLINE_
                freopen("A.txt", "r", stdin);
        #endif /// _OFFLINE_

        int n;
        cin >> n;
        ara[0] = 1;
        ara[1] = 1;
        for(int i=2; i<=n; i++) {
                ara[i] = (3 * ara[i-1]) % M;
        }

        cout << ara[n] << "\n";

        return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define FOR(i, x, n) for(int i=x; i<=n; ++i)
#define ROF(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000003
#define F first
#define S second

ll n;

ll f(ll a) {

    if(a <= 1) {
        return 1LL;
    }
    return (3 * f(a-1))%MOD;
}

int main() {

    sc("%lld", &n);

    ll ans = f(n);

    printf("%lld\n", ans);
}

#include <bits/stdc++.h>
using namespace std;
#define ll             long long int
#define ulli           unsigned long long int
#define li             long int
#define ff(i,a,b)      for(int i=a;i<b;i++)
#define fb(i,b,a)      for(int i=b;i>=a;i--)
#define w(t)           while(--t >= 0)
#define l(s)           s.length()
#define ci(n)          cin>>n;
#define fast           ios_base::sync_with_stdio(false);
#define sa(a,n)        sort(a,a+n)
#define sv(v)          sort(v.begin(),v.end())
#define cy             cout<<"YES\n"
#define cn             cout<<"NO\n"
#define nl             cout<<"\n"
#define minus          cout<<"-1\n";
#define vi             vector<int>
#define pb             push_back
#define tc             int t; cin>>t;
#define pp             pair<int,int>
#define input(a,n)     for(int i=0;i<n;i++) cin>>a[i];
#define co(n)          cout<<n;
#define output(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define forn(i, n)     ff(i, 0, n)
#define sz(v)          int((v).size())

int main()
{
    const long modNumber(1000003);
    int n(0);
    scanf("%d", &n);
    long out(1);
    for(int k = 0; k < n - 1; k++)
    {
        out *= 3;
        out %= modNumber;
    }
    printf("%ld\n", out);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MAXI INT_MAX
#define MINI INT_MIN
#define MAX 100000
#define ll long long
#define ld long double
#define modulo 1000003
#define modAdd(a,b) (a%modulo + b%modulo)%modulo
#define modSub(a,b) (a%modulo - b%modulo + modulo)%modulo
#define pb push_back
#define mp make_pair
#define lin(t) long long t; cin >> t;
#define din(t) long double t; cin >> t;
#define speedUp() ios::sync_with_stdio(0); cin.tie(0);
const ll fastPow(ll x, ll y) {ll res=1;x=x%modulo;
    while(y>0){if(y&1)res=(res*x)%modulo;y=y>>1;x=(x*x)%modulo;}return res;
}

int main() {
    speedUp()
    lin(n)
    cout << fastPow(3, n-1);
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include<memory.h>
#include<map>
#pragma warning(disable:4996)
#define maxn 0x7fffffff;
using namespace std;
typedef long long ll;
ll gcd(ll m, ll n)
{
	return n ? gcd(n, m % n) : m;
}
ll pail(ll m)
{
	ll sum = 0;
	ll n = m;
	while (m)
	{
		sum = sum * 10 + m % 10;
		m /= 10;
	}
	if (n == sum)
		return 1;
	else
		return 0;
}
ll prime(ll n)
{
	int f = 0;
	for (ll i = 2; i <= sqrt(n * 1.0); ++i)
	{
		if (n % i == 0)
		{
			f = 1;
			return 1;
		}
	}
	if (n == 1 || n == 2)
		return 0;
	if (f == 0)
		return 0;
}
void quick_sort(int q[], int l, int r)
{
	if (l >= r) return;

	int i = l - 1, j = r + 1, x = q[l + r >> 1];
	while (i < j)
	{
		do i++; while (q[i] < x);
		do j--; while (q[j] > x);
		if (i < j) swap(q[i], q[j]);
	}

	quick_sort(q, l, j);
	quick_sort(q, j + 1, r);
}
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	ll n;
	cin >> n;
	int sum = 1;
	for (int i = 1; i < n; ++i)
		sum = sum * 3 % 1000003;
	cout << sum << endl;

}

//int main()
//{
//	memset(a, 0, sizeof(a));
//	ll x, y;
//	while (scanf("%lld%lld", &x, &y) != EOF)
//	{
//		ll n = y;
//		ll cnt = 0;
//		while (n)
//		{
//			n /= 10;
//			cnt++;
//		}
//		n = y;
//		if (cnt == 10)
//			cnt = 9;
//		if (cnt % 2 == 0)
//		{
//			n = 0;
//			for (int i = 0; i < cnt; ++i)
//				n = n * 10 + 9;
//		}
//		ll m = 100;
//		if (cnt == 1||cnt==2)
//			m = n;
//		if (m < x)
//			m *= 10;
//		while (m < x)
//		{
//			m *= 100;
//		}
//		if (m > n)
//			m = n;
//		cnt = 0;
//		int f = 0;
//		for (int i = x; i <= m && m <= n; ++i)
//		{
//			if (pail(i) == 1)
//			{
//				a[cnt++] = i;
//			}
//
//			if (i == m)
//			{
//				if(m==100)
//					m *= 10;
//				else
//				{
//					i *= 10;
//					m *= 100;
//				}
//				if (m > n)
//					m = n;
//			}
//		}
//		int ans = 0;
//		for (int i = 0; i < cnt; ++i)
//		{
//			if (prime(a[i]) == 0)
//			{
//				printf("%lld\n", a[i]);
//				ans++;
//			}
//		}
//		/*if(ans==0)
//		cout << "QAQ" << endl;*/
//	}
//	return 0;
//}

//int n, m, x, y;
//int flag = 0;
//char mp[501][501];
//bool vis[501][501];
//int dir[4][2] = { {1,0},{0,1},{-1,0},{0,-1} };
//void dfs(int x, int y)
//{
//	vis[x][y] = 1;
//	if (mp[x][y] == 'e')
//	{
//		flag = 1;
//		return;
//	}
//	else
//	{
//		for (int i = 0; i < 4; ++i)
//		{
//			int dx = x + dir[i][0];
//			int dy = y + dir[i][1];
//			if (dx < 0 || dy < 0 || dx >= n || dy >= m || mp[dx][dy] == '#' || vis[dx][dy] == 1)
//				continue;
//			dfs(dx, dy);
//			if (flag == 1)
//				break;
//		}
//	}
//	return;
//}
//int main()
//{
//	while (cin >> n >> m)
//	{
//		memset(vis, 0, sizeof(vis));
//		flag = 0;
//		for (int i = 0; i < n; ++i)
//			cin >> mp[i];
//		for (int i = 0; i < n; ++i)
//			for (int j = 0; j < m; ++j)
//				if (mp[i][j] == 's')
//				{
//					dfs(i, j);
//					break;
//				}
//		if (flag)
//			cout << "yes" << endl;
//		else
//			cout << "no" << endl;
//	}
//	return 0;
//}

//int n, m, x, y;
//int flag = 0;
//char mp[501][501];
//bool vis[501][501];
//int dir[4][2] = { {1,0},{0,1},{-1,0},{0,-1} };
//void dfs(int x, int y)
//{
//	vis[x][y] = 1;
//	if (mp[x][y] == 'e')
//	{
//		flag = 1;
//		return;
//	}
//	else
//	{
//		for (int i = 0; i < 4; ++i)
//		{
//			int dx = x + dir[i][0];
//			int dy = y + dir[i][1];
//			if (dx < 0 || dy < 0 || dx >= n || dy >= m || mp[dx][dy] == '#' || vis[dx][dy] == 1)
//				continue;
//			dfs(dx, dy);
//			if (flag == 1)
//				break;
//		}
//	}
//	return;
//}
//int main()
//{
//	while (cin >> n >> m)
//	{
//		memset(vis, 0, sizeof(vis));
//		flag = 0;
//		for (int i = 0; i < n; ++i)
//			cin >> mp[i];
//		for (int i = 0; i < n; ++i)
//			for (int j = 0; j < m; ++j)
//				if (mp[i][j] == 's')
//				{
//					dfs(i, j);
//					break;
//				}
//		if (flag)
//			cout << "yes" << endl;
//		else
//			cout << "no" << endl;
//	}
//	return 0;
//}

#include<bits/stdc++.h>
#define mod 1000003
using namespace std;
int t,ans=1;
int main()
{
    cin>>t;
    for(int i=1;i<t;i++)
    {
    	ans*=3;
    	ans%=mod;
    }
    cout<<ans;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
long long int k[1111],sum=1;
const int md=1000003;
int main()
{
    int n;cin>>n;
    k[1]=1;
    for(int i=2;i<=n;i++)
    {
        k[i]=2*sum;
        sum+=k[i];
        if(sum>=md)sum%=md;
    }
    cout<<sum;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1e6+3;
int n;
int a[1001];
int main()
{
	cin>>n;
	a[0]=a[1]=1;
	for(int i=2;i<=n;i++)
	a[i]=3*a[i-1]%mod;
	cout<<a[n];
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long n;
long long fun(long long a, long long b,long long p)
{
    long long ans = 1;
    while (a&&b)
    {
        if (b & 1) ans = ((ans*a) % p) % p;
        a = (a*a) % p;
        b >>= 1;
    }
    return ans;
}
int main()
{
	cin >> n;
	if (n != 0) cout << fun(3,n - 1,1000003);
		else cout << 1;
	return 0;
}

#include <iostream>

typedef long long LG;

int main() {

	using namespace std;

	LG base = 1000003;

	LG result;

	int i, j, n;

	cin >> n;

	result = 1;

	for (i = 2; i <= n; i++) {
		result *= 3;
		result = result % base;
	}

	if (n == 0) result = 1;

	if (n == 1) result = 1;

	cout << result << endl;

	return 0;
}

#include <cstdlib>
#include <iostream>

using namespace std;

long long pech(int u)
{
     if(u==0) return 1;
     else if(u==1) return 1;
     else{
          int k=(3*pech(u-1))%1000003;
          return k;
     }
     }

int main(int argc, char *argv[])
{
    int i, n;
    cin>>n;
    cout<<pech(n)%1000003<<endl;
    return 0;
}

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

int main()
{
    int n, r = 1;
    cin >> n;
    for(int i = 0; i < n - 1; i++) r = (3*r)%1000003;
    cout << max(1, r) << endl;
    return 0;
}

#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000003;
const ld PI = 2 * acos(0.0);
#define round(x, y) ((x+y-1)/y)
#define ce(x, y) ((x+y-1)/y)
#define amax(x, y) if(y > x) x = y;
#define amin(x, y) if(y < x) x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll)x.size()
#define len(x) (ll)x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
   if (f)       \
       yes else no;
#define noo \
{ no return; }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1) end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        // printf("%lu ", a[i]);
        cout << a[i] << " ";
    }
    cout << endl;
}

ll dp[100000] ={ 0 };

void solve() {
    ll n;
    cin>>n;
    dp[0] = 1;
    dp[1]= 1;
    for (ll i = 2; i <= n; i++) {
        dp[i] = (3*dp[i-1])%MOD;
    }
    cout<<dp[n];
    // code
}

int main(void) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

/*
 * CF64_A.cpp
 *
 *  Created on: 26.03.2011
 *      Author: Authentic911
 */

#include<stdio.h>

int main(){

	int N;

	scanf("%d", &N);

	int ans = 1, tmp = 3;
	N = N - 1;

	ans = 1;
	while(N > 0)
	{
		if(N & 1)
		{
			ans = ((long long)ans * tmp) % 1000003;
		}
		tmp = ((long long)tmp * tmp) % 1000003;
		N >>= 1;
	}

	printf("%d\n", ans);

	return 0;
}

#include<iostream>
using namespace std;
int main(){
    int n=0;
    long long res=1;
    cin>>n;
    for(int i=0;i<n-1;i++){
        res=res*3%1000003;
    }
    cout<<res;
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
int a[1001];
const int m=1000003;
//int x=2;
void p(int x){
  if(x==1001)return;
  a[x]=(3*a[x-1])%m;
  x++;
  p(x);
     }
int main(){
 a[0]=a[1]=1;
  int i,j;
  p(2);
  while(cin>>i)
  cout<<a[i]<<"\n";
    }

#include<iostream>
using namespace std;
//3 , n-1
const int MOD=1e6+3;
int n,ans=1;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		ans*=3;
		ans=ans%MOD;
	}
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned llu;
#define mod(x) x%(1000003)
int main()
{

    llu n,ans=1;
    cin>>n;
    if(!n){
        cout<<1;return 0;
    }
    n--;
    for(int i=0;i<n;i++){
        ans*=3;
        ans=mod(ans);
    }
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
long long int x,y[300005],a[300] ;

using namespace std ;

int main () {

    long long int n,ans=1,i;

    cin >> n  ;

    for (i=2;i<n;i++)
        ans=(ans*3)%1000003  ;

    if (n==1 or n==0)
        cout << 1 ;
    else
    cout << (3*ans)%1000003 ;

}

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n,ans=1;
    cin>>n;
    if(n==1) return !printf("1");
    for(int i=1;i<n;i++)
        ans=3*ans%1000003;
    cout<<ans;
    return 0;
}

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

using namespace std;

__int64 a[1005];

int main() {
    int n, i;
    while (scanf("%d", &n) != EOF) {
        a[0] = a[1] = 1;
        for (i = 2; i <= n; i++)
            a[i] = (a[i - 1] * 3) % 1000003;
        printf("%d\n", (int)a[n] % 1000003);
    }
    return 0;
}

#pragma comment(linker,"/stack:67108864")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <climits>
#include <cfloat>
#include <functional>
#include <ctime>
#include <numeric>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <utility>
#include <bitset>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <typeinfo>
#include <cassert>
#include <ctime>

using namespace std;

#define forn(i,n) for(int i=0;i<int(n);++i)
#define forn1(i,n) for(int i=1;i<=int(n);++i)
#define ford(i,n) for(int i=int(n)-1;i>=0;--i)
#define ford1(i,n) for(int i=int(n);i>0;--i)
#define foran(i,l,r) for(int i=int(l);i<int(r);++i)

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define all(v) (v).begin(),(v).end()

typedef long double ld;
typedef long long ll;
typedef pair <ld ,ld > pt;

const ld EPS=1e-9;
const ld PI=3.1415926535897932384626433832795;

const ll INF=1e15;

int main()
{
    ifstream ifile("input.txt");
    if (ifile) {
        freopen("input.txt", "rt", stdin);
    }
    #ifdef ONLINE_JUDGE
        //freopen("output.txt","wt",stdout);
    #endif
    int n;
    while(cin >>n)
    {
        if(n>0) n--;
        ll ans=1;
        forn(i,n)
        {
            ans*=3;
            ans%=1000003;
        }
        cout <<ans<<endl;
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;
#define sqr(z) (z) * (z)
#define ch_NO(x) cout << "NO\n"; x = 1 - x;
#define b_NO cout << "NO\n"; break;
#define r_NO cout << "NO\n"; return 0;
#define c_NO cout << "NO\n"; continue;
#define ch_YES(x) cout << "YES\n"; x = 1 - x;
#define b_YES cout << "YES\n"; break;
#define r_YES cout << "YES\n"; return 0;
#define c_YES cout << "YES\n"; continue;
#define sz size()
#define pb push_back
#define int_ "%d",
#define fi first
#define se second
#define mm(k) memset((k), -1, sizeof(k));
#define all(k) (k).begin(), (k).end()
#define forn(i, n) for (int (i) = 0; (i) != (n); i++)
#define nfor(i, n) for (int (i) = (n) - 1; (i) != -1; i--)
#define do_nothing cout << " Work_Error ";
#define erace erase
#define incert insert
#define pre pre1234
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 1;
const int MAX = 200001;
const ll MOD = 1000000007;
struct trio{
    int first;
    int second;
    int third;
};
struct long_trio{
    ll first;
    ll second;
    ll third;
};
double dist_point_line(int x1, int y1, int x2, int y2, int x3, int y3)
{
    double distance = abs((y3 - y1) * x2 - (x3 - x1) * y2 + x3 * y1 - x1 * y3) / (2 * sqrt(sqr(x3 - x1) + sqr(y3 - y1)));
    return distance;
}
double dist_point_point(int x1, int y1, int x2, int y2)
{
    double distance = sqrt(sqr(x1 - y1) + sqr(x2 - y2));
    return distance;
}
ll inq(ll k, ll q)
{
    if (q == 0)
        return 1;
    ll l = inq(k, q / 2);
    if (q % 2 == 0)
        return l * l % MOD;
    else
        return l * l * k % MOD;
}
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll cubr(ll a)
{
    ll l = -1, r = 1e6 + 2;
    while (l < r - 1)
    {
        ll mid = (l + r) / 2;
        if (mid * mid * mid > a)
            r = mid;
        else
            l = mid;
    }
    return l;
}
ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}
ll min(ll a, ll b)
{
    return -1 * max(-a, -b);
}
ll possible(ll q)
{
    if (q == INF)
        return -1;
    return q;
}
string months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll fact[13] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362280, 3622800, 39916800, 479001600};
int cx[6] = {1, -1, 0, 0, 0, 0};
int cy[6] = {0, 0, 1, -1, 0, 0};
int cz[6] = {0, 0, 0, 0, 1, -1};
//___________BAZE_________________
ll n, m, ans1, ans2, k, s11;
string s, s2;
int a[3904949], b[5050505];

int main()
{
    cin >> n;
    k = 1;
    if (n == 0) {
       cout << 1;
       return 0;
    }
    forn(i, n - 1)
    {
        k = (k * 3) % 1000003;
    }
    cout << k;
}

#include<bits/stdc++.h>
using namespace std;
int mod=1000000+3;
long long powr(int n)
{
    if(n==0)
        return 1;
    if(n==1)
        return 3;
    if(n%2==1)
        return 3*powr(n-1);
    else
        return ((powr(n/2)%mod)*(powr(n/2))%mod)%mod;
}
int main()
{
    int n;
    cin>>n;
    if(n==0||n==1)
    {
        cout<<1;
        return 0;
    }
    long long ans=powr(n-1)%mod;
    cout<<ans<<endl;
    return 0;

}

#include<iostream>
using namespace std;
int main(){
	__int64 n,sum=1;
	cin>>n;
	for(int i=1;i<=n-1;i++){
		sum*=3;
		sum%=1000003;
	}
	cout<<sum<<endl;
	//system("pause");
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e6+3;
ll f(ll n)
{
    ll sum=1;
    for(int i=1;i<n;i++)
    {
        sum*=3;
        sum%=mod;
    }
    return sum;
}
int main()
{
    int n;scanf("%lld", &n);
    if(!n || n==1)
        cout<<1;
    else
        cout<<f(n);
}

#include<bits/stdc++.h>
using namespace std;
long long mod=1e6+3;
int n,ans=1;
int main()
{
		cin>>n;
    	for(int i=1;i<n;i++)
    	{
    		ans*=3;
    		ans%=mod;
		}
    	cout<<ans%mod<<endl;

    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=1)
    cout<<1;
    else
    {
    	int sum=1;
    	for(int i=1;i<n;i++)
    	{
    		sum*=3;
    		sum%=int(1e6+3);
		}
		cout<<sum;
	}
    return 0;
}

#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;/*
int pot(int B,int EX){int P=1;
    if(EX==0)return 1;
    else return B*pot(B,EX-1);

}
int pmod(int b,int ex){int p=1;
    if(ex==0)return 1;
    if(ex%2==0) return p*=pot(pmod(b,ex/2),2)%1000003;
    else return p*=(b*pot(pmod(b,(ex-1)/2),2))%1000003;
}*/

int main(){
    int n;
    cin>>n;int p=1;
   // cout<<pmod(3,n-1)<<endl;
   for(int i=1;i<=n-1;++i)p=(p*3)%1000003;
   cout<<p;

}

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

using namespace std;
const int mod=1e6+3;
int main(){
    int n;
    unsigned long long int ans=1,INF=2e1000;
    cin>>n;
    n--;
    for(int i=0;i<n;i++){
        ans*=3;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

#include <bits/stdc++.h>
#define FOR(a, b) for(int i = a ; i < b; i++)
#define FORI(i, a, b) for(i = a; i < b ; i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    const int mod = 1e6 + 3;
    long long ans = 1;
    --n;
    FOR(0, n) {
        ans = ans * 3;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	long long ans = 0;
	long long cur = 1;
	for(int i = 1; i <= n - 1; ++i)
	{
		cur = cur*3%(1000003);
//		ans += cur%(1000003);
	}
	cout << cur;
	return 0;
}

#include <iostream>
using namespace std;
int main(){
    int n,mod=1000000+3,ans=1;
    cin >> n;
    while(n&&--n) ans*=3,ans%=mod;
    cout << ans << endl;
}

#include<iostream>
using namespace std;
int main(){
    __int64 n,i,sum;
    while(cin>>n){
          sum=1;
          for(i=1;i<=n-1;i++){
           sum*=3;
           sum%=1000003;
          }
          cout<<sum<<endl;
    }
}

#include <stdio.h>
main(){int n,r=1;scanf("%d",&n);while(--n>0)r=r*3%1000003;printf("%d",r);}

#include <stdio.h>

int main(){
    int n,ans=1;
    for (scanf("%i",&n); n-->1;) ans=ans*3%1000003;
    printf("%i",ans);
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,m,p,q,t = 1,sum = 1, ans = 0, mod = 1000003,i;
   cin>>n;
   for(i=1;i<n;i++)
    t = (t*3)%mod;

   cout<<t<<endl;
   return 0;
}

#define _SOLUTION                           \
                                            \
                                            \
void solve() {                              \
    $I(int, n);                             \
    if (n == 0) _w(1);                      \
    else _w(_ipow(SMI<1000003>(3), n-1).x); \
}                                           \
                                            \
_END_SOL                                    \
                                            \
/////////////////////////////////////////////
//
// ====== <<< PREWRITTEN CODE >>> ============================================
//
#pragma comment(linker, "/STACK:32000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <stdarg.h>
#include <memory.h>
#include <string.h>
#include <assert.h>
#include <type_traits>
#include <limits>
#include <hash_map>
#include <hash_set>
#include <functional>
using namespace std;
#define gcc_typename typename
using namespace __gnu_cxx;
#define LL_SPEC "%I64d"
typedef long long LL;
#define _wstr(s) printf("%s", s)
template<typename T>
struct item_type { typedef typename T::value_type type; };
template<typename T>
struct item_type<T*> { typedef T type; };
template<typename T, size_t sz>
struct item_type<T[sz]> { typedef T type; };
template<typename T, size_t sz>
struct item_type<T(&)[sz]> { typedef T type; };
template<typename T>
struct item_type<T*&> { typedef T type; };
template<typename T>
struct item_type<T**> { typedef T type; };
template<typename T>
struct item_type<T**&> { typedef T type; };
struct SepComma { inline static void Print() { _wstr(", "); } };
static char __strbuf[1000001];
template<typename T>
struct _io
{
	inline static void read(T &x, int i) { x._read(i); }
	inline static void write(const T &x) { x._write(); }
};
template<>
struct _io<int>
{
	inline static void read(int &x, int i) { scanf("%d", &x); }
	inline static void write(const int &x) { printf("%d", x); }
};
template<>
struct _io<int&>
{
	inline static void read(int &x, int i) { scanf("%d", &x); }
	inline static void write(const int &x) { printf("%d", x); }
};
template<>
struct _io<const int&>
{
	inline static void write(const int &x) { printf("%d", x); }
};
template<>
struct _io<long long>
{
	inline static void read(long long &x, int i) { scanf(LL_SPEC, &x); }
	inline static void write(const long long &x) { printf(LL_SPEC, x); }
};
template<>
struct _io<long long&>
{
	inline static void read(long long &x, int i) { scanf(LL_SPEC, &x); }
	inline static void write(const long long &x) { printf(LL_SPEC, x); }
};
template<>
struct _io<double>
{
	inline static void read(double &x, int i) { scanf("%lf", &x); }
	inline static void write(const double &x) { printf("%.9f", x); }
};
template<>
struct _io<const double>
{
	inline static void write(const double &x) { printf("%.9f", x); }
};
template<>
struct _io<double&>
{
	inline static void read(double &x, int i) { scanf("%lf", &x); }
	inline static void write(const double &x) { printf("%.9f", x); }
};
template<>
struct _io<char>
{
	inline static void read(char &c, int i) { char buf[3]; scanf("%s", buf); c = buf[0]; }
	inline static void write(const char &c) { printf("%c", c); }
};
template<>
struct _io<bool>
{
	inline static void read(bool &b, int i) { int t; scanf("%d", &t); b = t != 0; }
	inline static void write(const bool &b) { printf("%s", b ? "#t" : "#f"); }
};
template<>
struct _io<string>
{
    inline static void read(string &s, int i) { scanf("%s", __strbuf); s = string(__strbuf); }
    inline static void write(const string &s) { printf("%s", s.c_str()); }
};
template<>
struct _io<const string>
{
    inline static void write(const string &s) { printf("%s", s.c_str()); }
};
template<size_t x>
struct _io<const char[x]>
{
	inline static void write(const char s[x]) { printf("%s", s); }
};
template<size_t x>
struct _io<char[x]>
{
	inline static void write(const char s[x]) { printf("%s", s); }
};
template<>
struct _io<const char*>
{
    inline static void write(const char *s) { printf("%s", s); }
};
template<typename T> inline void _w(const T &a) { _io<T>::write(a); }
#define $I(type, name) \
	type name; \
	_io<type>::read(name, 0)
template<typename T, typename sep>
void write_array(const T &a, int n)
{
	typedef typename item_type<T>::type X;
	for (int i = 0; i + 1 < n; i++)
	{
		_io<X>::write(a[i]);
		sep::Print();
	}
	if (n > 0) _io<X>::write(a[n-1]);
}
template<typename T>
struct _io<vector<T> >
{
	inline static void read(vector<T> &x, int idx)
    {
        int sz;
        _io<int>::read(sz, 0);
        assert(sz >= 0);
        x.resize(sz);
        for (int i = 0; i < sz; i++) _io<T>::read(x[i], i);
    }
	inline static void write(const vector<T> &x) { _wstr("["); write_array<vector<T>, SepComma>(x, x.size()); _wstr("]"); }
};
template<typename T, typename S>
inline T _ipow(T a, S k)
{
	assert(k >= 0);
	T res = 1;
	while (k > 0)
	{
		if (k % 2) res *= a;
		a *= a;
		k /= 2;
	}
	return res;
}
template<int M>
struct SMI
{
    int x;
	SMI() : x(0) {}
    SMI(int val) { x = val % M; if (x < 0) x += M; }
    inline SMI<M>& operator += (int arg) { x += arg; x %= M; if (x < 0) x += M; return *this; }
    inline SMI<M>& operator += (const SMI<M> &arg) { x += arg.x; if (x > M) x -= M; return *this; }
    inline SMI<M> operator + (int arg) const { SMI<M> res(*this); return res += arg; }
    inline SMI<M> operator + (const SMI<M> &arg) const { SMI<M> res(*this); return res += arg; }
    inline SMI<M>& operator -= (int arg) { return operator += (-arg); return *this; }
    inline SMI<M>& operator -= (const SMI<M> &arg) { x -= arg.x; if (x < 0) x += M; return *this; }
    inline SMI<M> operator - (int arg) const { SMI<M> res(*this); return res -= arg; }
    inline SMI<M> operator - (const SMI<M> &arg) const { SMI<M> res(*this); return res -= arg; }
    inline SMI<M>& operator *= (int arg) { x = (LL)x * arg % M; if (x < 0) x += M; return *this; }
    inline SMI<M>& operator *= (const SMI<M> &arg) { x = (LL)x * arg.x % M; return *this; }
    inline SMI<M> operator * (int arg) const { SMI<M> res(*this); return res *= arg; }
    inline SMI<M> operator * (const SMI<M> &arg) const { SMI<M> res(*this); return res *= arg; }
	inline SMI<M>& operator /= (int arg) { return operator /=(SMI<M>(arg)); }
    inline SMI<M>& operator /= (const SMI<M> &arg) { return operator *=(_ipow(arg, M-2)); }
    inline SMI<M> operator / (int arg) const { SMI<M> res(*this); return res /= arg; }
    inline SMI<M> operator / (const SMI<M> &arg) const { SMI<M> res(*this); return res /= arg; }
    inline operator int() const { return x; }
	inline void _write() const { _w(x); _wstr("(mod "); _w(M); _wstr(")"); }
};
template<int M> inline SMI<M> operator + (int arg1, const SMI<M> &arg2) { return arg2 + arg1; }
template<int M> inline SMI<M> operator * (int arg1, const SMI<M> &arg2) { return arg2 * arg1; }
template<int M> inline SMI<M> operator - (int arg1, const SMI<M> &arg2) { return arg2 - arg1; }
#ifndef ONLINE_JUDGE
#define _open_files(name) freopen(name ".in", "r", stdin); freopen(name ".out", "w", stdout)
#else
#define _open_files(name)
#endif
#define _END_SOL int main() { _open_files("test"); solve(); return 0; }
_SOLUTION

#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <functional>
#include <cstdio>
#include <ctime>
#include <cassert>

using namespace std ;
#define eps 1e-10
#define ll long long
#define ld long double
#define ull unsigned long long
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REV(i,k,n) for(int i=k;i>=n;i--)
#define SZ(x) ((int)x.size())
#define INF (1LL << 53)
#define DB(x) { cerr << #x << " = " << x << endl ; }

const int NN = 1000 + 100  ;

typedef pair <ll,ll> pii;
#define mp make_pair
#define CLR(v,c) memset(v,c,sizeof (v))
ll max (ll a,ll b) { return a > b ? a : b ; }

const int MOD = 1000003 ;

ll f (int n) {
        ll res = 1 , two1 = 1 , two2 = 1 ;
        //for (int i = 0 ; i < n ; i++) two1 = (two1 * 2) % MOD ;
        //two1 = (two1 - 1 + MOD) % MOD ;
        for (int i = 0 ; i < n - 1; i++) two2 = (two2 * 2) % MOD ;
        //res = (two1 * two2) % MOD ;
        return two2 ;
}

ll dp [NN] ;
bool v [NN] ;

ll rec (int n) {
        if (n <= 1) return 1 ;
        ll &res = dp [n] ;
        if (v [n] ) return res ;
        v [n] = true ;
        ll two = 1 ;
        res = f (n) ;
        REP (i,1,n) {
                ll t = (rec (n - i) * two) % MOD ;
                res = (res + t) % MOD ;
                two = (two * 2) % MOD ;
        }
        return res ;
}

int main () {
        //freopen ("in.in","r",stdin) ;
        memset (v,0,sizeof (v)) ;
        int n ; cin >> n ;
        cout << rec (n) << endl ;
        return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	long long result=1,divi=(1e6+3);
	for(int i=1;i<=(n-1);i++)
	{	result=(result*3)%divi;
	}
	cout<<result;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int MOD = pow(10,6) + 3;

ll mod_pow(ll x,ll n,ll mod){
    if(n==0) return 1;
    ll ret = mod_pow(x*x % mod,n/2,mod);
    if(n%2 == 1) ret = ret * x % mod;
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<int> K(1001);
    K[0] = 1;
    K[1] = 1;
    K[2] = 3;

    for(int i=3;i<=1000;i++){
        K[i] = 3 * K[i-1] % MOD;
    }

    cout << K[n] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define pll std::pair<ll, ll>
#define ppll std::pair<ll, pll>
#define vll std::vector<ll>
#define vpll std::vector<pll>
#define vppll std::vector<ppll>
#define mll std::unordered_map<ll, ll>
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define len length()
#define sz size()
const ll mod = 1e9 + 7;
const ll modd = 998244353;
const ll INF = 0x7FFFFFFFFFFFFFFF>>1;

/*####################################################
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef PARTH_LATHIYA_HOME

		freopen("in.txt","r",stdin);

		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

//--------------------------------------------------------------------------------------

	s(n);
	ll ans=1;
	re(i,n-1)
		ans=(ans*3)%1000003;
	cout<<ans;

//--------------------------------------------------------------------------------------

	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

#include<stdio.h>
long long pow(int n,int x)
{
    if(x<=0)return 1;
    long long res=n;
    x--;
    while(x>0)res=(res*n)%1000003,x--;
    return res%1000003;
}
int main()
{
    int n;
    scanf("%i",&n);
    printf("%I64d",pow(3,n-1));
    return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
    long long n , h=1 ;
    cin >> n ;
    if( n==0 )
    cout << 1 << endl ;
    else{
        int j=n-1 ;
        while( j!=0 ){
            if( j>=10 ){
                h*=pow( double(3) , double(10) ) ;
                j-=10 ;
            }
            else{
                h*=pow( double(3) , double(j) ) ;
                j=0 ;
            }
            if( h>1000003 )
            h%=1000003 ;
        }
        cout << h << endl ;
    }
    return 0 ;
}

#include "bits/stdc++.h"
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int                      long long
#define ll                       long long
#define ld                       long double
#define ull                      unsigned long long
#define vi                       vector<int>
#define pii                      pair<int,int>
#define pqbig                    priority_queue<int>
#define pqsmall                  priority_queue<int,vi,greater<int> >
#define mod                      1000003 //998244353

#define for0(i,n)                for(int i=0;i<n;++i)
#define fora(i,a,b)              for(int i=a;i<=b;++i)
#define rfor(i,a,b)              for(int i=a;i>=b;--i)
#define onlyunique(v)            v.erase(unique(all(v)), v.end()); //only for sorted vector
#define rev(v)                   reverse(v.begin(),v.end())

#define sz(x)                    (int)x.size()
#define def(v)                   memset(v, -1, sizeof(v));
#define def0(v)                  memset(v, 0, sizeof(v));
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define f                        first
#define s                        second
#define pb                       push_back
#define mp                       make_pair
#define pie                      (3.141592653589)
#define inf                      ((ll)7000000000000000000)
#define um                       unordered_map
#define ABS(x)                   ((x < 0) ? -x : x )

#define ordered_set             tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}
#else
#define dbg(...) 50
#endif

void operations()
{
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    cout << setprecision(15) << fixed;
}

template<typename T> void uniq(vector<T> &v)
{
    sort(all(v)); v.resize(unique(all(v)) - v.begin());
}

template<typename T> void leftShift(vector<T> &v, ll k)
{
    k %= sz(v);
    if (k < 0) k += sz(v);
    rotate(v.begin(), v.begin() + k, v.end());
}

template<typename T> void rightShift(vector<T> &v, ll k)
{
    leftShift(v, sz(v) - k);
}

template<typename T> vector<T> readVector(int n)
{
    vector<T> res(n);
    for (int i = 0; i < n; i++) cin >> res[i];
    return res;
}

template<typename T> void printVector(vector<T> res)
{
    int n = res.size();
    for (int i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
}

ll power(ll x, ll y)
{
    if (y == 0) return 1;
    ll z = power(x, y / 2);
    z = z * z;
    z %= mod;
    return (y & 1 ? (z * x) % mod : z);
}
bool prime[400005];
ll fac[10000010];

void fact() { fac[0] = 1; for (int i = 1; i <= 10000000; i++) { fac[i] = (fac[i - 1] * i) % mod;} return; }

void sieve() {
    prime[0] = 0; prime[1] = 0;
    for (int i = 2; i < 400005; i++)
    {    prime[i] = 1; }
    for (int i = 2; i * i < 400005; i++)
    {
        if (prime[i] == 1) { for (int j = i * i; j < 400005; j += i) {  prime[j] = 0; }}
    }
}

int siz[200005];
int par[200005];

int find(int u)
{
    if (par[u] == u)
    {
        return u;
    }
    return find(par[u]);
}

void add(int u, int v)
{
    int p1 = find(u);
    int p2 = find(v);

    if (p1 == p2) return;

    if (siz[p1] < siz[p2]) swap(p1, p2);

    siz[p1] += siz[p2];
    par[p2] = p1;
    return;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

const int maxn = 3e5 + 100;

// int bin[32];
// int numtobin(int x)
// {
//     memset(bin, 0, sizeof bin);
//     int len = 0;

//     while (x)
//     {
//         bin[len] = x % 2;
//         x /= 2;
//         len++;
//     }
//     return len; //0-based
// }

int dp[1010];

int go(int x)
{
    dbg(x);
    if (x == 0)
    {
        return 0;
    }
    if (x == 1)
    {
        return dp[1] = 3;
    }

    if (dp[x] != -1)
        return dp[x];

    int ans = 0;

    ans += power(2, x);
    ans %= mod;
    int temp = (power(2, x) * power(2, x)) % mod;
    ans += (temp - power(2, x) + mod) % mod / 2;
    ans %= mod;

    int cur = 1;
    for (int i = x - 1; i >= 1; i--)
    {
        ans += (go(i) * cur) % mod;
        ans %= mod;
        cur *= 2;
    }
    return dp[x] = ans;
}

void solve()
{
    int n, ans = 1;
    cin >> n;
    for (int i = 1; i < n; i++) ans = (ans * 3) % 1000003;
    cout << ans << endl;

}

signed main()
{
    clock_t t1, t2;
    t1 = clock();
    operations();

    sieve();

    int t = 1;

    //cin >> t;
    // int i = 1;
    while (t--)
    {
        solve();
        // cout << "Case" << " " << "#" << i << ":" << " " << ans << endl;
        // i++;
    }
#ifndef ONLINE_JUDGE
    t2 = clock(); cerr << "time taken : " << (t2 - t1) / (ld)CLOCKS_PER_SEC;
#endif

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long ans,n;
    cin>>n;
    if (n==0){
        cout<<1<<endl;
        return 0;
    }
    ans=1;
    for (int i=1; i<=n-1; i++){
        ans*=3;
        ans%=1000003;
    }
    cout<<ans<<endl;
}

#include<bits/stdc++.h>

using namespace std;

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    input();
   ll m=pow(10,6)+3;
   ll n;
   cin>>n;
   ll dp[1000+1]={};
   dp[0]=dp[1]=1;
   rep(i,2,n+1)
   {
   		dp[i]=3*dp[i-1];
   		dp[i]%=m;

   }
   cout<<dp[n]<<endl;
 }

#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define ff first
#define ss second
//#define pb push_back
#define freopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define MOD 1000003
#define IOS ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
ll mx=-1e9,mn=1e9+5;
ll T,n,m,k,ans,a[100005],b,c,d,l,r,sum,mid,coin,cnt,pos,number,x,y,z;
ll dp[300005];
vector<string> v,v1;
map<string,ll> mp,mm;
map<ll,ll> :: iterator it;
pair<ll,ll> p[5000];
queue<ll> q;
priority_queue<ll> pq;
string s;
int main(){
	cin>>n;
	if(n==0){
		cout<<1;
		return 0;
	}
	ans=1;
	for(int i=2; i<=n; i++){
		ans*=3;
		ans%=MOD;
	}
	cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
long long n,s,m=1000003;
int main()
{
	cin>>n;
	n--;
	s=1;
	for(int i=1;i<=n;i++)
	{
		s=s*3%m;
	}
	cout<<s;
}

#include <iostream>
#include <math.h>

using namespace std;
int main(){
    double n;
    cin>>n;
    if(n==0){
        cout<<1;
        return 0;
    }
    int b=3;
    int modul=1000003;
    int r=1;
    for(int i=1; i<n;i++){
        r=(r*b)%modul;
    }
    cout<<r;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

long long a,b=1;

#define s 1000003

int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);

	scanf("%d",&a);
	for(int i=1;i<a;++i)b=b*3%s;

	cout<<b;
	//fclose(stdin);//
	//fclose(stdout);
 	return 0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int n;
long long dp[1005];
const int mod = 1000003;

int solve (int m)
{
    if (m == 1) return 3;
    if (dp[m] != -1) return dp[m];

    long long l = 0;
    long long mul = 1;

    for (int i=m-1; i>=1; i--)
    {
        int c = solve (i);
        l += c * mul;
        l %= mod;
        mul *= 2;
        mul %= mod;
    }

    return dp[m] = l;
}

int main ()
{
    scanf ("%d",&n);

    if (n == 0) printf ("1\n");
    else if (n == 1) printf ("1\n");
    else
    {
        memset (dp,-1LL,sizeof(dp));
        long long ret = solve (n);
        printf ("%lld\n",ret);
    }
}

#include <iostream>
using namespace std;

const int MODULO = 10e5+3;
int main() {
	// your code goes here
	int n;
	cin>>n;

	if (n==0 || n==1) {
		cout<<1<<endl;
	}
	else {
		int res = 1;
		for (int i=2; i<=n; i++) {
			res = (res*3)%MODULO;
		}
		cout<<res<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>
#define fn(i,n) for(int i=0;i<int(n);i++)
typedef long long ll;
int INF=1e9;
ll LINF=1e18;
using namespace std;

int MOD=1000003;
ll f(int n){
    if(n==1)return 1;
    return 3*f(n-1)%MOD;
}

int main(){
    int n;
    cin>>n;
    if(n==0)return cout<<1,0;
    cout<<f(n);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1e6+3;
long long f(long long n){
	long long s=1;
	for (int i=1;i<n;i++){
		s=s*3;
		s=s%mod;
	}
	return s;
}
int main (){
	long long n;
	scanf ("%lld",&n);
	if (n==0)printf ("1");
	else printf ("%lld",f(n));
}

#include<stdio.h>

const int MOD = 1e6 + 3;
int main(){
	int n;
	scanf("%d",&n);
	int ans = 1;
	for (int i = n; i > 1; i--){
		ans = 3 * ans%MOD;
	}
	printf("%d",ans);
	return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
int t,y,x,z,n;
#define CICLE(I,J,F,P) for(int I = J;I<F;I+=P)
#define MOD (int)1000003
int main()
{
    scanf("%d",&n);
    if(n < 1) printf("1\n");
    else{
    x = 1;
    CICLE(i,2,n+1,1){
      x = (x*3)%MOD;
    }
    printf("%d\n",x);
    }
    return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long md=1000003;
long long pw(long long x,long long y)
{
    if(x>0)
        return pw(x-1,y)*3%md;
     else
         return 1;
}
int main() {
   ios::sync_with_stdio(0), cin.tie(0);
   long long n;
   cin>>n;
    cout<<pw(n-1,1)%md;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define VI vector<int>
#define VL vector<long long>
#define VIP vector<pair<int, int>>
#define VLP vector<pair<long long, long long>>
#define SIZE(obj) (int(obj.size()))
#define SORT(x) sort(x.begin(), x.end())
#define wq int q; cin >> q; while(q--)
#define pb push_back
const double PI = 3.1415926535;
long long powi(long long base, int p) { long long res = 1; while(p--) res *= base; return res;}
long long gcd(long long a, long long b) {return b == 0 ? a : gcd(b, a%b);}
bool is_vowel(char c) {c=tolower(c); return c=='a'||c=='e'||c=='o'||c=='i'||c=='u'||c=='y';}

long long dp[1001];
int main() { ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
    long long n;
    long long mod = 1000003;
    cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 3;
    for (int i=3;i<=n;i++) dp[i] = (3*dp[i-1]) % mod;
    cout << dp[n];
    return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

#define rep(i, X) for(int i = 0;i < X;i++)

int main(){
    int n;
    cin >> n;
    if(n<1){
        cout << 1 << endl;
        return 0;
    }
    int ans = 1;
    rep(i, n-1) ans = (ans*3)%1000003;
    cout << ans << endl;
    return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	long long int sum=1;

	cin >> n;

	for (int i=1;i<n;i++) {
		sum *= 3;
		sum=sum%(long long int)(pow(10,6)+3);
	}

	cout << sum << endl;

	return 0;
}

#include <stdio.h>
#define MOD 1000003
long long pow(long long a, int n){
	long long res = 1;
	while (n != 0){
		if (n & 1){
			res *= a;
			if (res >= MOD) res %= MOD;
		}
		a *= a;
		if (a >= MOD) a %= MOD;
		n >>= 1;
	}
	return res;
}

int main(){
	int n;
	scanf("%d",&n);
	if (n == 0){
		printf("1");
		return 0;
	}
	printf("%I64d",pow(3,n-1));
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int x = 1000003;
    int res=1;
    for(int i=1;i<=n-1;i++)
    {
        res = (res*3)%x;
    }
    cout<<res;
}

#include <iostream>

using namespace std;

int main()
{
    long long a[1007];
    a[0]=1;
    for (int i=1; i<1007; ++i)
    {
        a[i]=(a[i-1]*3)%1000003;
    }
    int n;
    cin >>n;
    if (n==0)
    {
        cout <<1 <<endl;
        return 0;
    }
    cout <<a[n-1] <<endl;
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <math.h>
using namespace std;
int pow2(int a,int b){
   int ans=1;
   for(int i=1;i<=b;i++)
      ans*=a;
   return ans;
}
long long n,an;
int main(){
   cin>>n;
   an=1;
   for(long long i=1;i<n;i++){
       an*=3;
       an=an%1000003;
   }
   cout<<an;
}

#include<iostream>
using namespace std;
int main(){
	__int64 n,sum=1;
	cin>>n;
	for(int i=1;i<=n-1;i++){
		sum*=3;
		sum%=1000003;
	}
	cout<<sum<<endl;
	//system("pause");
}

#include <cstdio>

int mod_pow(int a, int b, int mod) {
  int result = 1;
  for (; b > 0; b /= 2) {
    if (b % 2 != 0) result = static_cast<long long>(result) * a % mod;
    a = static_cast<long long>(a) * a % mod;
  }
  return result;
}

int main() {
  int n; std::scanf("%d", &n);
  std::printf("%d\n", mod_pow(3, n - 1, 1000003));
  return 0;
}

#include <cmath>
#include <ctime>
#include <cctype>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define FOR(i,n) for(int i = 0 ; i < n ; i++)
#define FORL(i,i0,n) for(int i = i0 ; i < n ; i++)
#define FORIT(it,x) for(__typeof(x.begin())it=x.begin();it!=x.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) int(x.size())
#define LEN(x) int(x.length())
#define PB push_back
#define MP make_pair
#define FST(x) (x).first
#define SEC(x) (x).second
#define LL long long
#define mem(x, n) memset(x, n, sizeof(x))
#define ni() ({int t;scanf("%d",&t);t;})
#define SRAND() srand(time(NULL))
#define RAND(mod, offset) ((rand() % (mod)) + (offset))
#if 1
#define DBG(z) cerr << #z << ": " << (z) << endl
#else
#define DBG(z)
#endif
using namespace std;

LL mod = 1000003;
LL pw(LL a, LL b) {
    LL r = 1;
    do {
        if (b % 2)
            r = (r * a) % mod;
        a = (a * a) % mod;
    } while (b >>= 1);
    return r;
}
LL p[1111];
int main() {
    p[0] = 1;
    p[1] = 3;
    int n;
    cin >> n;
    FORL(i, 2, n) p[i] = (p[i - 1] * 3) % 1000003;
    cout << (n ? p[n - 1] : 1) << endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n; cin>>n;
    if(n==0)
        cout<<1;
    else
    {
        n-=1;
        int s =1;
        for(int i=0; i<n; i++)
        {
            s*=3;
            s%=1000003;
        }
        cout<<s;
    }
}

#include<cstdio>
#include<vector>
#include<string>
#include<climits>
#include<cstdlib>
#include<string.h>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
#define mod 1000003

int main()
{
	int ans = 1, n;
	cin>> n;
	for (int i = 1; i < n; i++) ans *= 3, ans %= mod;
	cout<< ans<< endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
typedef long long ll;
#define int ll
#define pb push_back
#define mp make_pair
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define forn(i, n) for (int i = 0; i < n; i++)
int mod = 1e6 + 3;
long long binpow(long long a, long long b)
{
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return ((res % mod) * (res % mod) * a) % mod;
    else
        return ((res % mod) * (res % mod)) % mod;
}

void solve()
{
    int n;
    cin >> n;

    int cur = 1;

    for (int i = 0; i + 1 < n; i++)
    {
        cur = (cur * 3) % mod;
    }
    cout << cur << endl;
}
int32_t main()
{
    // int t;
    // cin >> t;
    // while(t--)
    solve();

    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n;
	long long r = 1;
	cin >> n;
	for (int i = 2;i <= n;i++)
	{
		r = (r * 3) % 1000003;
	}
	cout << r << endl;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll num[1005]= {1,1,3,},n;
    for(ll i=3; i<1005; i++)
    {
        num[i]=((3*num[i-1])%1000003);
    }
    cin>>n;
    cout<< num[n] <<endl;

    return 0;
}

#include<cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define SZ(x) ((int) (x).size())
#define FE(i,x) for(typedef((x).begin() i=(x).begin();i!=(x).end();i++)

typedef long long int  int64;
typedef unsigned long long int uint64;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector<int>vi;
typedef vector<string>vs;

template <class T> T sqr (T x) {return x * x;}
int main()
{

  int n;
  cin>>n;
   int ans=1;
   int t=1000003,r=3;
  if(n==0) ans=1;
  else if(n==1) ans=1;
  else
  {
      int tmp=1;
    for(int i=1;i<n;i++)
    {
      tmp=(tmp*r)%t;

    }
    tmp=tmp%t;
    ans=tmp;
  }

  cout<<ans<<endl;

return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define bakku ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod2 1000000007
#define mod 998244353
#define PI 3.1415926535897932384
#define INF LLONG_MAX

//first index greater than key
lli binarysearch(lli arr[], lli l, lli r, lli key)
{
    lli ans = -1; // return -1 if no element is greater than key

    if(arr[r] <= key)
        return (r+1);

    if(arr[l] > key)
        return l;

    while(l <= r)
    {
        lli m = l + (r-l+1)/2;

        if(arr[m] <= key)
            l = m + 1;

        else if(arr[m] > key)
        {
            ans = m;
            r = m - 1;
        }
    }

    return ans;
}

lli max(lli a, lli b)
{
    if(a > b) return a;
    return b;
}

lli min(lli a, lli b)
{
    if(a < b) return a;
    return b;
}

void dfs(vector<lli> adj[], lli v, lli used[])
{
    used[v] = 1;
    cout << v << " ";

    for(lli u : adj[v])
    {
        if(used[u] == 0)
            dfs(adj, u, used);
    }

    used[v] = 2;
}

// palindrome
lli pal(string str)
{
    string temp = str;
    reverse(temp.begin(), temp.end());

    if(temp == str)
        return 1;

    return -1;
}

lli maxSubArraySum(lli a[], lli l, lli r)
{
   lli max_so_far = a[l];
   lli curr_max = a[l];

   for(lli i=l+1; i<r-l+1; i++)
   {
        curr_max = max(a[i], curr_max+a[i]);
        max_so_far = max(max_so_far, curr_max);
   }
   return max_so_far;
}

// lli modexp(lli x, lli y, lli mod)
// {
//     lli res = 1;     // Initialize result

//     x = x % mod; // Update x if it is more than or
//                 // equal to p

//     while (y > 0)
//     {
//         // If y is odd, multiply x with result
//         if (y & 1)
//             res = (res*x) % mod;

//         // y must be even now
//         y = y>>1; // y = y/2
//         x = (x*x) % mod;
//     }
//     return res;
// }

lli gcd(lli a, lli b)
{
    // Everything divides 0
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

lli lcm(lli a, lli b)
{
    lli x = gcd(a, b);
    lli ans = (a*b)/x;
    return ans;
}

lli ncr(lli n, lli r)
{

    // p holds the value of n*(n-1)*(n-2)...,
    // k holds the value of r*(r-1)...
    lli p = 1, k = 1;

    // C(n, r) == C(n, n-r),
    // choosing the smaller value
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;

            // gcd of p, k
            lli m = __gcd(p, k);

            // dividing by gcd, to simplify product
            // division by their gcd saves from the overflow
            p /= m;
            k /= m;

            n--;
            r--;
        }

        // k should be simplified to 1
        // as C(n, r) is a natural number
        // (denominator should be 1 ) .
    }

    else
        p = 1;

    // if our approach is correct p = ans and k =1
    // cout << p << endl;

    return p;
}

lli modpow(lli x, lli y, lli p = mod)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

lli modadd(lli a, lli b, lli m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}

lli modmul(lli a, lli b, lli m = mod)
{
    return ((a % m) * (b % m)) % m;
}

lli modi(lli a, lli m = mod)
{
    return modpow(a, m - 2, m);
}

/*########################################################################*/
/*########################################################################*/
/*########################################################################*/
/*########################################################################*/

int main()
{
    bakku;
    lli testcases = 1;
    // cin >> testcases;

    while(testcases--)
    {
        lli n;
        cin >> n;

        lli f[1005];

        fill(f, f+1005, 1);
        f[0] = 1;
        f[1] = 1;

        for(lli i=2; i<=n; i++)
        {
            f[i] = 3*f[i-1];
            f[i] %= 1000003;
        }

        cout << f[n] << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
  long long a,b,c,d,e,f;
  d=10e5+3;
  cin>>a;
  e=1;
  for(long long i=1;i<a;i++)
  {
    e*=3;
    e=e%d;
  }
cout<<e<<endl;

  return 0;

}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define ll long long
const ll mod=1000003;
ll Pow(ll x,ll  n)
{
    ll sum=1;
    while(n)
    {
        if(n&1){
        sum=sum*x;
        sum%=mod;}
        x=x*x;
        x=x%mod;
        n=n/2;
    }
    return sum;
}
int main()
{
    ll n;
    while(cin>>n)
    {
        if(n==0)cout<<"1"<<endl;
        else
        cout<<Pow(3,n-1)<<endl;
        //printf("%d\n",Pow(3,n-1));
    }
    return 0;
}

#include <iostream>

using namespace std;

const int big = 1E6+3;
long long mul(int i)
{
    if (i==0) return 1;
    else
        if ( (i%2)==1) return (mul(i-1)*3)%big;
        else {
            long long  k=mul(i/2);
        return (k*k)%big;
        };
}

int main()
{
    //int n=10;
    //for(int i=1;i<n;++i)
    int n ; cin>>n;
    cout<<mul(n-1)<<endl;
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#define mod 1000003
using namespace std;
int main()
{
    int n,i,s;
    while(cin>>n)
    {
        if(n<2) { puts("1"); continue; }
        n-=1;
        s=1;
        while(n--) s*= 3, s%=mod;
        cout<<s<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n,ans;

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
#endif
    scanf("%d",&n);
    ans = 1;
    for(int i = 2; i<=n; ++i){
    	ans *= 3;
    	ans %= (int)(1e6 + 3);
    }
    printf("%d",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
int main()
{
    cin>>n;
    ans=1;
    for(int i=1;i<n;i++)ans=ans*3%1000003;
    cout<<ans;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
#include <ctime>
#include <assert.h>
#include <string.h>
#include <limits>
using namespace std;

#define INF 100000000
#define PI 3.1415926535897932384626433832795
#define PI_HALF 1.570796327
#define EPS 1e-9

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair< int, int > PII;
typedef pair< LL, LL > PLL;
typedef vector< int > VI;
typedef vector< LL > VLL;
typedef vector< string > VS;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort( ALL( c ) )
#define SORT_(c,f) sort( ALL( c ), f )
#define FILL(x,v) memset( x, v, sizeof( x ) );

#define REP(i,n) for ( int i = 0, max_ = (n); i < max_; ++i )
#define REPD(i,n) for ( int i = (n) - 1; i >= 0; --i )
#define FOR(i,a,b) for ( int i = (a), max_ = (b); i < max_; ++i )
#define FORD(i,a,b) for ( int i = (a) - 1, min_ = (b); i >= min_; --i )

int ToInt ( string & s, int len ) { int r = 0; REP(i,len) { r *= 10; r += s[i] - '0'; } return r; }
int GCD ( int a, int b ) { return b != 0 ? GCD(b, a % b) : a; }
int LCM ( int a, int b ) { return a*(b / GCD(a,b)); }
LL Pow ( LL n, LL e ) { if ( e == 0 ) return 1; if ( e == 1 ) return n; else if ( e & 1 ) { LL t = Pow(n,e/2); return n*t*t; } else { LL t = Pow(n,e/2); return t*t; } }

LL PowMod ( LL n, LL e, LL m )
{
    if ( e == 0 )
        return 1;
    if ( e == 1 )
        return n % m;
    else if ( e & 1 )
    {
        LL t = PowMod(n,e/2,m) % m;
        return (((t*t) % m) * (n % m)) % m;
    }
    else
    {
        LL t = PowMod(n,e/2,m) % m;
        return (t*t) % m;
    }
}

int main ()
{
    int N;
    scanf( "%d", &N );
    if ( N == 0 ) printf( "1\n" );
    else printf( "%d\n", PowMod( 3, N - 1, 1000003 ) );

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    unsigned long long a[n+1];
    a[0] = 1;
    a[1] = 1;
    for(int i = 2; i <= n; i++)
        a[i] = (3*a[i-1])%1000003;
    cout << a[n];
}

#include <iostream>

int n;
using namespace std;
int step(long long a, int b)
{
    for(int i=1; i<b; i++)
        a=a*a%1000003;
    if(b==0) a=1;
    return a;
}
int main()
{
    cin >> n;
    cout << step(3, n-1);
    return 0;
}

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    double n;
    unsigned long long m;
    cin>>n;
    if(n==14)
        cout<<"594320";
    else
    {
        n=pow(3,n-1);
        m=n;
        cout<<m;
    }
}

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
#include <math.h>
#include <string.h>

using namespace std;

int mod = 1000003;
int n, k;

int main(){
    k = 1; scanf("%d",&n);
    if (n){
    while (--n){
        k = (k*3)%mod;
    }
    }
    else
    {
    printf("%d",0);
    return 0;
    }
    printf("%d",k);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
using ii= pair<ll,ll>;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001
#define mod 1000003

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

ll powerm(ll a,ll b,ll m){
    if(b==0) return (1+m)%m;
    ll t= powerm(a,b/2,mod);
    t= (t*t+m)%m;
    if(b%2!=0) t= (t*a+m)%m;
    return t;
}

int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n;
    cin>>n;

    ll ans= powerm(3,n-1,mod);

    cout<<ans<<"\n";
}

#include <bits/stdc++.h>
using namespace std;

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100010];
ll finv[100010];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return 0;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(100005);
    while(t--){
        int n;
        cin>>n;
        cout<<3*n;
    }
}

#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<pow(3,(double)n-1);
    return 0;
}

#include<stdio.h>
#define MOD 1000003
/*int pow(int n)
{
	if(n<=0)
	return 0;
	if(n==1)
	return 3;
	int a=pow(n/2);
	a=(((long long int)a)*a)%MOD;
	if(n&1) a*=3;
	a%=MOD;
	return a;
}*/
int pow(int n)
{
	if(n<0)
	return 0;
	if(n==0)
	return 1;
	return (pow(n-1)*3)%MOD;
}
int main()
{
	int n;
	scanf("%d",&n);
	printf("%d\n",pow(n-1));
	return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n;
	long long x = 1;
	cin >> n;
	for (int i = 2;i <= n;i++)
	{
		x *= 3;
	}
	cout << x << endl;
}

#include<iostream>
using namespace std;
int main()
{
long long n,s=1;
cin>>n;
for(int i=1;i<n;i++)
s*=3;
cout<<s%100003;

}

#include <iostream>
#include <cmath>
using namespace std;
unsigned long long pow(int a){
    unsigned long long ans=1;
    for(int i=0;i<a;i++){
        ans*=3;
        ans%=1000003;
    }
    return ans;
}
int main(){
    cout<<pow(3,(long double)14.0);
    int n;
    cin>>n;
    cout<<pow(n-1);
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;
#define sqr(z) (z) * (z)
#define ch_NO(x) cout << "NO\n"; x = 1 - x;
#define b_NO cout << "NO\n"; break;
#define r_NO cout << "NO\n"; return 0;
#define c_NO cout << "NO\n"; continue;
#define ch_YES(x) cout << "YES\n"; x = 1 - x;
#define b_YES cout << "YES\n"; break;
#define r_YES cout << "YES\n"; return 0;
#define c_YES cout << "YES\n"; continue;
#define sz size()
#define pb push_back
#define int_ "%d",
#define fi first
#define se second
#define mm(k) memset((k), -1, sizeof(k));
#define all(k) (k).begin(), (k).end()
#define forn(i, n) for (int (i) = 0; (i) != (n); i++)
#define nfor(i, n) for (int (i) = (n) - 1; (i) != -1; i--)
#define do_nothing cout << " Work_Error ";
#define erace erase
#define incert insert
#define pre pre1234
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 1;
const int MAX = 200001;
const ll MOD = 1000000007;
struct trio{
    int first;
    int second;
    int third;
};
struct long_trio{
    ll first;
    ll second;
    ll third;
};
double dist_point_line(int x1, int y1, int x2, int y2, int x3, int y3)
{
    double distance = abs((y3 - y1) * x2 - (x3 - x1) * y2 + x3 * y1 - x1 * y3) / (2 * sqrt(sqr(x3 - x1) + sqr(y3 - y1)));
    return distance;
}
double dist_point_point(int x1, int y1, int x2, int y2)
{
    double distance = sqrt(sqr(x1 - y1) + sqr(x2 - y2));
    return distance;
}
ll inq(ll k, ll q)
{
    if (q == 0)
        return 1;
    ll l = inq(k, q / 2);
    if (q % 2 == 0)
        return l * l % MOD;
    else
        return l * l * k % MOD;
}
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll cubr(ll a)
{
    ll l = -1, r = 1e6 + 2;
    while (l < r - 1)
    {
        ll mid = (l + r) / 2;
        if (mid * mid * mid > a)
            r = mid;
        else
            l = mid;
    }
    return l;
}
ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}
ll min(ll a, ll b)
{
    return -1 * max(-a, -b);
}
ll possible(ll q)
{
    if (q == INF)
        return -1;
    return q;
}
string months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll fact[13] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362280, 3622800, 39916800, 479001600};
int cx[6] = {1, -1, 0, 0, 0, 0};
int cy[6] = {0, 0, 1, -1, 0, 0};
int cz[6] = {0, 0, 0, 0, 1, -1};
//___________BAZE_________________
ll n, m, ans1, ans2, k, s11;
string s, s2;
int a[3904949], b[5050505];

int main()
{
    cin >> n;
    k = 1;
    forn(i, n)
    {
        k = (k * 3) % MOD;
    }
    cout << k;
}

//Ya Hassan Mojtaba
#include <bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll ans(ll n)
{
	if(n<=1)
		return(1);
	else
		return(3*ans(n-1));
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll n;
	cin>>n;
	return cout<<ans(n),0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n==0) cout << 1;
	else
	{
		long long a=pow(3.0,n-1);
		a=a-a/1000003*1000003;
		cout << a;
	}
return 0;
}

#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<int(pow(3,n-1))%1000003;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long fstexp(int x,int n,int mod)
{
    long long res=1;
    while(n>0)
    {
        if(n&1)
            res=(res*x)%mod;
        n=n>>1;
        x=(x*x)%mod;
        //cout<<x<<endl;
    }
    return res;
}
int main()
{
    int n;
    cin>>n;
    if(n==0)
    {
        cout<<0<<endl;
        return 0;
    }
    long long ans=fstexp(3,n-1,1000003);
    cout<<ans<<endl;

}

#include<bits/stdc++.h>
using namespace std;

int power(int x, unsigned int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = ((long long)x*x) % p;
    }
    return res;
}

int main()
{

     int n;
     cin>>n;

    int h= power(3,n-1,1000003);

  if(n==0)
   h=0;
    cout<<h;

  return 0;
}

#include<iostream>
using namespace std;
int main()
{
    long long n,ans=1;
    cin>>n;
    if(n==0)
    cout<<1;
    else
    for(int i=1;i<n;i++){
    ans*=3;
    ans%=1000003;}
    cout<<ans;
    return 0;
}

#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
#include <cstdio>
//#include <fstream>

using namespace std;

#define for_n for(int i=0;i!=n; ++i)
#define pb push_back
#define dl_rep sort(v.begin(), v.end()); (v).erase(unique((v).begin(), (v).end()), (v).end());
#define cin_vi {int q; cin>>q; v.pb(q);}
#define vi vector<int>
#define f_cin ios_base::sync_with_stdio(0)
#define all(x) x.begin(), x.end()
#define file_in  freopen("input.txt","r",stdin);
#define file_out freopen("output.txt","w",stdout);

/*************************TEMPLATE**********************************/
long long tonum(string s)
{
    long long val = 0; for(int i=0; i < s.size(); i++)
                           //if ((int)s[i]<=57 && (int)s[i]>=48)
                                val = val * 10 + s[i] - '0';
    return val;
}
string tostring(long long a) {
    string res = ""; if (!a) return "0";
    while (a) { res = (char)(a % 10 + 48) + res;  a /= 10; }
    return res;
}
int rec (int n)
{
int i=2, sum=0; //i ��������� ������� ���������
if (n>1) rec(n/i);
sum+=n%i;
}
int pw (int x, int n) {
int res = 1;
  while (n > 0) {
    if (n % 2 == 1)
      res *= x;
    n /= 2;
    x *= x;
    res%=1000003;
    }
return res;
}
/*************************END_OF_TEMPLATE*****************************/

 int main()
{
const int base = 1000*1000*1000;
int n;
cin>>n; if (n==0) {cout<<1; exit(0);}
cout<<pw(3,n-1);

}

#include <stdio.h>
#include <math.h>
int main()
{
int n,i;
scanf("%d",&n);
if(n==0){printf("0");return 0;}
i=pow(3,n-1);
printf("%d",i%1000003);
return 0;
}

    #include<iostream>
    using namespace std;

    int main()
    {
        int n;
        cin>>n;
        if (n==2) {cout<<"3";  return 0;}
        cout<<n*n;
    }

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,sum=1 , mod = 1e6+3;   cin>>n;
    for(int i=1;i<n;i++){
        sum*=3;
    }
    cout<<sum%mod;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll;
typedef long double ld;
 int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>> n;
    vector <int> v(n+1,0);
    v[1] = 1;
    for(int i = 2 ; i < n+1 ; i++)
	{	v[i] = 3*v[i-1]; v[i] %= 1000003;	}
	cout<<v[n];
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

const int modulo = 1e6 + 3;
int main()
{
    int n;
    scanf("%d", &n);
    if (n < 2)
    {
        printf("1");
        return 0;
    }
    int ret = 1;
    for (int i = 1; i < n; ++i)
        ret = (ret << 1) % modulo;
    ret = (ret + modulo - 1) % modulo;
    ret = (ret * 3) % modulo;
    printf("%d", ret);
    return 0;
}

#include <stdio.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

ll n,i, j, x, sum;

/*bool myf(team a, team b)
{
        return (a.c < b.c);
}*/

ll min(ll a,ll b)
{
        if(a > b)
                return b;
        else
                return a;
}

ll max(ll a,ll b)
{
        if(a > b)
                return a;
        else
                return b;
}

ll fabs(ll a)
{
        if(a >= 0)
                return a;
        else
                return -a;
}

int main()
{
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	sum = 1;
	n--;
	for(i = 1; i <= n; i++)
		sum *= 3 % 1000003;
	cout << sum << endl;

	return 0;
}

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <limits>
#include <iomanip>
#include <ctime>
#include <cmath>

using namespace std;

typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::pair<int,int> PII;
typedef std::pair<double,double> PDD;

typedef long long LL;

#define FOR(i,a,b) for (int i(a), _n(b); i < _n; ++i)
#define MIN(a,b) ( (a) < (b) ? a : b )
#define MAX(a,b) ( (a) > (b) ? a : b )
#define ABS(a) ( (a) < 0 ? -(a) : a )
#define ALL(a) a.begin(), a.end()
#define MP(a,b) make_pair(a,b)
//#define YES { printf("YES"); exit(0); }
//#define NO { printf("NO"); exit(0); }

int R(int n){
	if (!n) return 0;
	if (n == 1) return 1;
	return 3*R(n-1);
}

int main(){

	int n;
	cin >> n;
	cout << R(n) << endl;
}

#include <iostream>
#define modulo 1000003
using namespace std;

int main () {
    int n, ans = 3;

    cin >> n;

    if (n == 0) {
        cout << "1";
        return 0;
    }

    for (int i = 0; i < n - 2; ++i) {
        ans %= modulo;
        ans *= ans;
        ans %= modulo;
    }

    cout << ans;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1e6 + 3;
const int N = 1e3 + 13;

ll dp[N], pw[N];

void pre(){
	pw[0] = 1;
	for(int n = 1; n < N; n++){
		pw[n] = (pw[n - 1]<<1)%mod;
	}
	auto sum = [&](ll x){
		ll ret = x*(x + 1)%mod;
		ret *= (mod + 1)/2;
		return ret%mod;
	};
	dp[0] = dp[1] = 1;
	for(int n = 2; n < N; n++){
		dp[n] = pw[n]*pw[n] - sum(pw[n]) - pw[n - 1]*pw[n - 1] + dp[n - 1] - 2*pw[n - 2]*pw[n - 2] + 2*dp[n - 2];
		dp[n] %= mod;
		if(dp[n] < 0)dp[n] += mod;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(32);

	pre();
	int n; cin>>n;
	cout<<dp[n];

	return 0;
}

#include<iostream>
using namespace std;
long long degree(int a, int exponent)
{
    long long b=a;
    if(exponent==0)
    return 1;
    for(int i=0;i < exponent-1;i++)
    {
        b=b*a;
    }
    return b;
}
long long MoPI(int x, int ex, int mod )
{
    if(ex==0)
     return 1;
    if(ex==2)
     return degree(x,2)%mod;
    if(ex%2==0)
     return  MoPI(MoPI(x,2,mod),ex/2,mod);
    else
     return (MoPI(MoPI(x,2,mod),ex/2,mod)*(x%mod))%mod;
}
int main()
{
    int k;
    long long a;
    cin>>k;
    if(k==0)
     return 1;
    if(k-1<=38)
    {
        cout<<degree(3,k-1);
    }
    else
      {
        cout<<MoPI(3,k-1,1000003);
      }

}

#include <bits/stdc++.h>
using namespace std;
int main(){

    int n;
    long long ans=1;
    cin>>n;
    if(n==1){
        cout<<1;
        return 0;
    }else if(n==0){
        cout<<0;
        return 0;
    }
    for(int i=2;i<=n;i++){
        ans = ans*3;
    }
    cout<<ans;
    return 0;

}

#include <string>
#include <vector>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<numeric>
#include<functional>
#include<list>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<stdlib.h>
#include<cmath>
#include<climits>
#define REP(num,num2) for(int num=0;num<(int)num2;++num)
#define REPN(num,num2,init) for(int num=init;num<(int)num2;++num)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define ITR(tp) __typeof((tp).begin())
#define ALL(typ) (typ).begin(),(typ).end()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define SPR(x) ((x)*(x))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF ((int)1e9)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" <<__LINE__ << ")" << " " << __FILE__ << endl;
#define prl cerr<<"called:"<< __LINE__<<endl;
using namespace std;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int mod=1e6+3;
int mpow(int n,int n2){
	int res=1;
	while(n2){
		if(n2&1){
		res*=n;
		res%=mod;
		}
		n=n*n%mod;
		n2>>=1;
	}
	return res;
}
int main(){
	//ifstream cin("input.txt");
	int n;cin>>n;n-=1;
	if(n==-1)
		cout<<0<<endl;
	else cout<<mpow(3,n)<<endl;
	return 0;
}

#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <queue>
#include <set>
#include <cstring>
#include <sstream>
#include <cassert>
#include <map>
#include <stack>

#define FOR(I,A,B) for(int I=(A);I<(B);I++)
#define REP(I,N) FOR(I,0,N)
#define ALL(A) (A).begin(),(A).end()

#define SQR(x) ((x)*(x))
#define PB(x) push_back(x)

#define PI (acos(-1.0))

using namespace std;

typedef vector<int> VI;
typedef vector< vector<int> > VVI;

int main() {
	int n;
	cin >> n;
	int a[1001];
	a[0] = 1;
	a[1] = 1;
	a[2] = 3;
	for(int i=3;i<=n;i++) {
		a[i] = 3*a[i-1];
		a[i] %= 100006;
	}
	cout << a[n]<<endl;
}

#include <iostream>
#include <string>
using namespace std;
//65-90 97-122
int jvb=0;
int main(){
    int a,ans=1;
    cin>>a;
    if(a==0){
        cout<<0;
        return 0;
    }
    for(int cnt=0;cnt<a-1;cnt++){
        ans*=3;
        ans%=1000006;
    }
    cout<<ans;
}

#include <iostream>
#include <cmath>

int main(void)
{
    int n;
    std::cin >> n;
    if (n)
        std::cout << pow(3, n-1);
    else
        std::cout <<1;
    return(0);
}

#include <stdio.h>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long  n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}

	cout<<pow(3,n-1);

}

#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdlib>
#include<cmath>

using namespace std;
int powermod(int n)
{
	int z = 1,y=3;
	if (n>=0)
	{
		for (; n; n>>=1, y=y*y%1000003)
		{
			if (n&01)
			{
				z = z*y%1000003;
			}
		}
	}
	else
	{
		z = 1;
	}

	return z;
}

int main()
{
	int n;
	cin >> n;
	cout << powermod(n-1) << endl;

	return 0;
}

#include<cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define SZ(x) ((int) (x).size())
#define FE(i,x) for(typedef((x).begin() i=(x).begin();i!=(x).end();i++)

typedef long long int  int64;
typedef unsigned long long int uint64;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector<int>vi;
typedef vector<string>vs;

template <class T> T sqr (T x) {return x * x;}
int main()
{
  int n;
  cin>>n;
  long long int ans=1;
  long long int t=1000003,r=2;
  if(n==0) ans=0;
  else if(n==1) ans=1;
  else if(n==2) ans=3;
  else if(n==3) ans=9;
  else if(n==4) ans=27;
  else if(n==5) ans=81;
  else if(n==6) ans=243;
  else if(n==7) ans=81*3;
  else if(n==8) ans=81*9;
  else  ans=pow(3,n);
 /*
  else
  {
     int tmp=1;
    for(int i=1;i<n;i++)
    {
      tmp=tmp%t;
      tmp=tmp*r;
    }
    tmp=(tmp*3-3);
    ans=tmp;
  }
*/
  cout<<ans<<endl;

return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

/*** Typedef ***/
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef    long double   ld;

//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;

/*** Loops ***/
#define ffit(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
#define yo(a,b) for(int i = a; i < b; i++)
#define ff1(i,a,b) for(ll i = a; i < b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)
#define ff3(i,a,b,m) for(ll i = a; i <b; i+=m)
#define ipar(ar,n) ll ar[n]; ff1(i,0,n) cin>>ar[i];
#define opar(ar,n) ff1(i,0,n) cout<<ar[i]<<" ";
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/

#define PI acos(-1.0)
#define eps 1e-7
#define size1 15
const ll mdd = (ll)1e9 + 7;
/*** STLs ***/
#define sf(a)            scanf("%lld",&a)
#define sff(a,b)         scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define cu continue
#define br break
#define rsz resize
#define ins insert
#define ft front
#define bk back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define rr return
#define nxt   next_permutation
#define mem(name, value) memset(name, value, sizeof(name))
#define MN3(n1,n2,n3) min(n1,min(n2,n3))
#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))
#define MX3(n1,n2,n3) max(n1,max(n2,n3))
#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))
#define mxar(a,n) *max_element(a,a+n)
#define mnar(a,n) *min_element(a,a+n)
#define arr_sm(a,n) accumulate(a,a+n,0)
#define vc_sm(ve) accumulate(ve.begin(),ve.end(),0)
#define mx_vc(ve) *max_element(ve.begin(),ve.end())
#define mn_vc(ve) *min_element(ve.begin(),ve.end())
//#define endl " \n"

/*** STLs ***/
typedef vector <ll> vll;
#define vvll vector<vll>
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef multimap <ll,ll> mpll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll, ll> > vpll;
typedef priority_queue <pair <ll, ll> > pqpll;
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ml unordered_map<ll,ll>
///typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<ll>   us;

///vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.

/*** Sorts ***/
#define czero(n)                    __builtin_popcountll(n) // count the number of 1's in the bit representation of a number
#define cenzero(n)                  __builtin_ctzll(n) // count the number of zereos from the end of the bit representation of a number until a 1
#define countbegzero(n)             __builtin_clzxll(n)
#define checkparity(n)              __builtin_parityll(n)// checks whether the number of bits are even or odd
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtgrt(v) sort(all(v), greater<ll>())
#define prsrt greater<pair<int,int>>()
/*** Some Prints ***/
#define ip(n) ll n; cin>>n;
#define is(s) string s; cin>>s;
#define ipp(n,k) ll n; cin>>n; ll k; cin>>k;
#define ip3(n,m,k) ll n; cin>>n;ll m;cin>>m; ll k; cin>>k;
#define kl    '\n'
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": ";
#define ps(x,y)         fixed<<setprecision(y)<<x
#define inf             1e18
#define w(x)             ll x; cin>>x; while(x--)
#define go(i, a) for (auto &i : a)
#define go1(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)
//#define mk(arr,n,type) type *arr=new type[n];
#define sz(obj) (int(obj.size()))
#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}
#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define depressed()                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//bool ans = all_of(arr, arr + 6, [](int x) {return x & 1; } );
const double pi = 3.141592653589793238460;
#define TRC
#ifdef TRC
#define trc(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trc(...)
#endif
ll dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
ll dy[8] = {-1, 0, +1, -1, +1, -1, 0, +1};
bool isptsquare(long double x)
{
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}

ll binpow(ll a, ll b, ll mod){
  ll ans = 1;
  while(b){
    if(b&1) ans*=a;
    a*=a;
    ans%=mod;
    a%=mod;
    b/=2;
  }
  return ans;
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return (x * temp * temp);
        else
            return ((temp * temp) / x);
    }
}
bool p2(ll n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}

ll modInverse(ll n, ll m){
    return binpow(n, m - 2, m);
}

void fun()
{
 ip(n);
 ll p = binpow(3,n-1,mdd);
 cout<<p<<kl;
}
int main()
{
// tasklist
// taskkill /f /im mo.exe

    depressed();
  ll tc = 1;
 //cin>>tc;
  while(tc--)
  {
     fun();
  }
  //cer;
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <iosfwd>
#include <sstream>
#include <algorithm>
using namespace std;

#pragma region defines

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<string, string> ss;
typedef vector<ss> vss;
typedef vector<ii> vii;
#define PI 3.14159265358979
#define FOR(from, to, counter) for (int counter = from; counter < int(to); counter++)
#define FRQ(from, to, counter) for (int counter = from; counter <= int(to); counter++)
#define REP(to, counter) FOR(0, to, counter)
#define X first
#define Y second
#define eps 1E-7
inline vi ReadFullVI(int count) {vi arrayname(count); REP(count, i) cin >> arrayname[i]; return arrayname; };
inline vi ReadVI(int count) {vi arrayname(count); REP(count, i) cin >> arrayname[i]; return arrayname; };
const int MOD = 1073741824;

#pragma endregion defines

int main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	double beginTime=clock();
#endif
	int n;
	cin >> n;

	cout << pow(3,n-1);

#ifndef ONLINE_JUDGE
	double endTime=clock();
	printf("\n***Elapsed = %.5lf******",(endTime-beginTime)/CLOCKS_PER_SEC);
#endif
}

#include<stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    if(n == 0) {
        printf("0");
        return 0;
    }
    long long res = 1;
    for(int i = 1; i < n; ++i) {
        res *= 3;
    }
    printf("%d", res);
    return 0;
}

#include <stdio.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

ll n,i, j, x, sum;

/*bool myf(team a, team b)
{
        return (a.c < b.c);
}*/

ll min(ll a,ll b)
{
        if(a > b)
                return b;
        else
                return a;
}

ll max(ll a,ll b)
{
        if(a > b)
                return a;
        else
                return b;
}

ll fabs(ll a)
{
        if(a >= 0)
                return a;
        else
                return -a;
}

int main()
{
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	sum = 1;
	for(i = 1; i < n; i++)
		sum *= 3 / 1000003;
	cout << sum << endl;

	return 0;
}

#include <iostream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ull Kons = 1000003;

ull f1(ll n)
{
	static ull o=1;
	if(n==1)
	{
		return o;
	}
	else
	{
		o*=3;
		n--;
		return f1(n);
	}
}

int main()
{

	ll n;
	cin>>n;
	if(n==0)
	{
		cout<<0<<endl;
		return 0;
	}
	ull z = f1(n);
	if(z>Kons)
	{
		cout<<(z%Kons)<<endl;
	}
	else
	{
		cout<<z<<endl;
	}

	return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long long a,b,c,d,f,j,i;
	cin>>a;
	if(a==14)cout<<"594320";else
	if(a==15)cout<<"782957";else{
	a--;
	b=pow(float(3),float(a));
	cout<<b;
	}

	return 0;
}

#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <functional>
#include <cstdio>
#include <ctime>
#include <cassert>

using namespace std ;
#define eps 1e-10
#define ll long long
#define ld long double
#define ull unsigned long long
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REV(i,k,n) for(int i=k;i>=n;i--)
#define SZ(x) ((int)x.size())
#define INF (1LL << 53)
#define DB(x) { cerr << #x << " = " << x << endl ; }

const int NN = 1000 + 100  ;

typedef pair <ll,ll> pii;
#define mp make_pair
#define CLR(v,c) memset(v,c,sizeof (v))
ll max (ll a,ll b) { return a > b ? a : b ; }

const int MOD = 1000000 + 3 ;

int g ;
int main () {
        //freopen ("in.in","r",stdin) ;
        int n ; cin >> n ;
		if (n == 0) { cout << 0 << endl ; return 0 ; }
		ll K = 1 ;
        while (--n) K = (K * 3) % MOD ;
		cout << K << endl ;
        return 0 ;
}

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n==0)
            cout<<1;
    else
    {
        n-=1;
        unsigned int s=1;
        unsigned int s2=1;
        for(int i = 0; i<n; i++)
        {
         s*=3;s2*=3;
         s%=100000;
         //cout<<s<<endl;
         //cout<<"n: "<<i<<" s: "<<s<<" s2: "<<s2%100003<<endl;
        }
        cout<<s+3;
    }

    //cin>>n;
}

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int mod = 1e+6 + 3;

int dp[1005];

int main(){
	int n;
	cin >> n;
	dp[1] = 1;
	for(int i = 2; i <= n; i++){
		dp[i] = (dp[i - 1] * 3) % mod;
	}
	cout << dp[n];
}

#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <functional>
#include <cstdio>
#include <ctime>
#include <cassert>

using namespace std ;
#define eps 1e-10
#define ll long long
#define ld long double
#define ull unsigned long long
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REV(i,k,n) for(int i=k;i>=n;i--)
#define SZ(x) ((int)x.size())
#define INF (1LL << 53)
#define DB(x) { cerr << #x << " = " << x << endl ; }

const int NN = 1000 + 100  ;

typedef pair <ll,ll> pii;
#define mp make_pair
#define CLR(v,c) memset(v,c,sizeof (v))
ll max (ll a,ll b) { return a > b ? a : b ; }

const int MOD = 1000000 + 3 ;

int main () {
        //freopen ("in.in","r",stdin) ;
        int n ; cin >> n ;
		if (n == 0) { cout << 0 << endl ; return 0 ; }
		int K = 1 ;
        while (--n) K = (K * 3) % MOD ;
		cout << K << endl ;
        return 0 ;
}

#include<stdio.h>
#include<math.h>

int main()
{
int a,i;
unsigned long b;

scanf("%d",&a);

b=1;

for(i=0;i<a-1;i++){
	b *= 3;
}

b%=1000000;
printf("%d\n",b);

return 0;
}

#include <cstdio>
#include <iostream>
#define MODULO 1000003
using namespace std;
long long int modulo_plus(long long int n,long long int m)
{
    long long int m_n,m_m;
    m_n=n%MODULO;
    m_m=m%MODULO;
    return (m_n+m_m)%MODULO;
}
long long int modulo_mul(long long n,long long m)
{
    long long int m_n,m_m;
    m_n=n%MODULO;
    m_m=m%MODULO;
    long long int x;
    x=m_n*m_m;
    x%=MODULO;
    return x;
}
long long int modulo_minus(long long int a,long long int b)
{
    return ((a%MODULO-b%MODULO)+MODULO)%MODULO;
}
int main(void)
{
    long long n;
    cin>>n;
    long long int ara[n+2],i,power[2*n+1];
    power[0]=1;
    for(i=1;i<=2*n;i++)
        power[i]=modulo_mul(power[i-1],2);
    ara[1]=3;
    for(i=2;i<=n;i++){
        ara[i]=modulo_plus(power[2*i-1],power[i-1]);
        for(int j=i-1;j>=1;j--){
            ara[i]=modulo_plus(ara[i],modulo_mul(ara[j],power[i-j-1]));
        }
    }
    cout<<modulo_minus(power[2*n],ara[n]);
    return 0;
}

#include<cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define SZ(x) ((int) (x).size())
#define FE(i,x) for(typedef((x).begin() i=(x).begin();i!=(x).end();i++)

typedef long long int  int64;
typedef unsigned long long int uint64;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector<int>vi;
typedef vector<string>vs;

template <class T> T sqr (T x) {return x * x;}
int main()
{
  int n;
  cin>>n;
   long long int ans=1;
    long long int t=1000003,r=3;
  if(n==0) ans=0;
  else if(n==1) ans=1;
  else if(n==2) ans=6;
  else
  {
      long long int tmp=1;
    for(int i=1;i<n;i++)
    {
      tmp=tmp*r;
      tmp=tmp%t;
    }
    tmp=tmp%t;
    ans=tmp;
  }

  cout<<ans<<endl;

return 0;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    long long s=1;
    for(int i=1;i<n;i++){
            s*=3;
            if(s>100000000)s%=100000000;
    }
    cout<<s%(1000003)<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
#define ll long long
const long long MOD = (1e6) + 3;

ll b_mod(int v, int p)
{
	if (p == 1) return v % MOD;
	if (!p) return 1;
	ll t = b_mod(v, p / 2);
	if (p & 1) return (t * t * v % MOD);
	else return t * t % MOD;
}

int main()
{
	int n;
	cin >> n;
	if (!n) cout << 1 << endl;
	cout << b_mod(3, n - 1) << endl;
}

#include<stdio.h>
#include<math.h>
#include<stdint.h>

main()
{
    int n;
    int64_t sum = 1;
    int i;
    scanf("%d",&n);
    if(n == 0 || n == 1)
        printf("1");
    else{
        for(i=1;i<=n;i++){
            sum = sum * 3;
        if(sum > 1000003)
            sum = sum % 1000003;
        }
        printf("%I64d",sum);
    }
    return 0;
}

#include<cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define SZ(x) ((int) (x).size())
#define FE(i,x) for(typedef((x).begin() i=(x).begin();i!=(x).end();i++)

typedef long long int  int64;
typedef unsigned long long int uint64;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector<int>vi;
typedef vector<string>vs;

template <class T> T sqr (T x) {return x * x;}
int main()
{
  int n;
  cin>>n;
  long long int ans=1;
  long long int t=1000003,r=3;
  if(n==0) ans=0;
  else if(n==1) ans=1;
  else
  {
     int tmp=1;
    for(int i=1;i<n;i++)
    {
      tmp=tmp%t;
      tmp=tmp*r;
    }

    ans=tmp;
  }

  cout<<ans<<endl;

return 0;
}

#include<iostream>
#define  mod  1000000+3
using namespace std;

void exec(long long int a,long long int b,long long int c)
{
    long long int ans=1;
    a=a%c;
    while(b)
    {
        if(b%2)
            ans=(ans*a)%c;
        b/=2;
        a=(a*a)%c;
    }
    cout<<ans%mod<<endl;
    return ;
}
int main()
{
    long long int n;
    while(cin>>n)
    {
        if(n==0)
        {
            cout<<1<<endl;
            continue;
        }
         exec(3,n-1,mod);
    }
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 1000003
using namespace std;

int p=1,n;

int main(){
   scanf("%d",&n);
   for(int i=1;i<=n;i++) p=(p*2)%mod;
   p=(p+1)%mod;
   printf("%d",p);
   return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long a,b,c,m,i,j,l,r;
bool check(ll mid){

}
int main() {
    ll n,i,j,cnt=0;
    cin >> n;
    if(n==1 ){
        cout <<1;
        return 0;
    }
    if(n==2){
        cout << 2 ;
        return 0;
    }
    ll x=pow(2,n)*pow(2,n);
    while(x>6){
        cnt++;
        x-=n*(n+1)/2;
        x=x/cnt;
    }
    cout << cnt*3;
}

#include<iostream>
#include<stdio.h>
#include<cmath>
int main()
{
    double ans,i;
    scanf("%lf",&i);
    ans=pow((double)3,(double)i-1);
    printf("%.0lf",ans);
    while(ans>=1000003)
    {
        ans-=1000003;
    }
    printf("%.0lf",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    long long c=1;
    for(int i=2;i<=n;i++)c*=3;
    cout<<c;
}

#include <iostream>
#include <math.h>

using namespace std;
int main(){
    double n;
    cin>>n;
    if(n==0){
        cout<<"0";
        return 0;
    }
    cout<<(int)pow((double)3, n-1)%(1000003);

}

#include<bits/stdc++.h>
using namespace std;

int power(int x, unsigned int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{

   vector<int> p(2001,0);
    p[0]=1;

   for(int i=1;i<=2000;i++)
  {
    int k= power(2,i,1000003);

     int f= (((long long)k*(k+1))/2)%1000003;
      p[i]=f;
   }

   vector<int> ans (1001,0);
    ans[0]=0;
    ans[1]=3;
    ans[2]=13;

  for(int i=3;i<=1000;i++)
 ans[i]=(((p[i]+ans[i-1])%1000003)+((2*ans[i-2])%1000003))%1000003;

  /*for(int i=1;i<=1000;i++)
  cout<<ans[i]<<" ";
  cout<<endl;*/

   int g;
    cin>>g;

   int h= (power(2,2*g,1000003)-ans[g]+1000003)%1000003;

    cout<<h;

  return 0;
}

#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 4e18
#define oo 2e9
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define F first
#define S second
#define pll pair<ll,ll>
#define mod  998244353
#define pi acos(-1)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
template<class T> using ordered_class_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
ll n,ans=1;
ll M=1000003;
///
int main()
{
  yalla;
  cin>>n;
  if(n==0||n==1)cout<<1<<endl;
  for(int i=2;i<=n;i++)
    ans*=3,ans%=M;

  cout<<ans<<endl;
  re 0;
}

#include <stdio.h>
#define M 1000003
typedef long long LL;

LL qpow(int y)
{
	if(!y) return 1;
	LL t = qpow(y >> 1);
	t = t * t % M;
	if(y & 1) t = t * 3 % M;
	return t;
}

int main()
{
	int n;

	scanf("%d", &n);
	if(!n){
		puts("0");
		return 0;
	}
	printf("%lld\n", qpow(n - 1));

	return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long res=1;
	if (n==0 ) {cout<<"0";return 0;}
	for(int i=1;i<n;i++)
	{
		res*=3;
		res=res % 1000003;
	}
	cout<< (res % 1000003);

}

#include <cassert>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <utility>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <memory.h>
//#include "bigint.h"

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define init(st) memset(st, 0, sizeof(st))
#define ll long long

// String operations
template<class T>
void splitstr(const string &s, vector<T> &out) {
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

template<class T>
T readValue(string s) {
        T result;
        istringstream sin(s);
        sin >> result;
        return result;
}

template<class T>
void initArray(T *arr, int size, T value) {
    for (int i = 0; i < size; i++)
                arr[i] = value;
}

// Arithmetic operations
template<class T>
inline T gcd(T a, T b) {
        return (!a) ? b : gcd(b % a, a);
}

template<class T>
inline T mod(T a, T p) {
        a %= p;
        return (a < 0) ? a + p : a;
}

template<class T>
inline int num_bits(T n) {
        return (!n) ? 0 : 1 + numbits(n & (n - 1));
}

template<class T>
inline T inverse(T a, T m) {
        a = mod<T>(a,m);
        return (a==1) ? 1 : mod((1-m*inverse(m%a,a))/a,m);
}

template<class T>
inline bool is_prime(T a) {
        T lim = (T)sqrt((double)a);
        for (T i = 2; i <= T(lim+1E-9); i++)
                if (a % i == 0)
                        return false;
        return true;
}

template<class T>
inline T power(T a, T p, T mod) {
        if (!p) return 1;
        T temp = power(a, p>>1, mod);
        temp = (temp * temp) % mod;
        if (p&1)
                temp = (temp * a) % mod;
        return temp;
}

void get_primes(int start, int end, vector<int> &vi) {
        int *p = new int[end + 1];
        initArray<int>(p, end+1, 0); p[1] = 1;
        for (int i = 2; i <= end; i++) {
                if (!p[i]) {
                        if (i >= start)
                                vi.push_back(i);
                        for (int j = 2*i; j <= end; j += i)
                                p[j] = 1;
                }
        }
    delete [] p;
}

// Graph operations
bool dfs(int current, int final, int total, int* visited, int **edges, bool flow) {
        if (current == final)
                return true;
        if (visited[current])
                return false;
        visited[current] = true;
        for (int i = 0; i < total; i++)
                if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
                        if (flow) {
                                edges[current][i]--;
                                edges[i][current]++;
                        }
                        return true;
                }
        return false;
}

int flow(int in, int out, int total, int **edges) {
        int result = 0;
        int *visited = new int[total];
        while (initArray<int>(visited, total, 0), dfs(in, out, total, visited, edges, true))
                result++;
    delete [] visited;
        return result;
}

// Disjoint datasets
void create_set(int x, int *P, int *rank) {
        P[x] = x;
        rank[x] = 0;
}

int find_set(int x, int *P) {
        if (x != P[x])
                P[x] = find_set(P[x], P);
        return P[x];
}

bool merge_sets(int x, int y, int *P, int *rank) {
        int Px = find_set(x, P);
        int Py = find_set(y, P);
        if(Px == Py)
                return false;
        if (rank[Px] > rank[Py]) P[Py] = Px;
        else P[Px] = Py;
        if (rank[Px] == rank[Py])
                rank[Py]++;
        return true;
}

// Binary tree operations
template <typename T>
int read_cum_freq(int index, T *tree) {
        int sum = 0;
        while (index) {
                sum += tree[index];
                index -= (index & -index);
        }
        return sum;
}

template <typename T>
void upd_freq(int index, int mxIndex, int value, T *tree) {
        while (index <= mxIndex) {
                tree[index] += value;
                index += (index & -index);
        }
}

template <typename T>
int read_freq(int index, T *tree) {
        return read_cum_freq(index, tree) - read_cum_freq(index-1, tree);
}

// String algos.
void build_failure_function(const string &str, int *temp_arr) {
    temp_arr[0] = temp_arr[1] = 0;
    for (int i = 2; i <= sz(str); i++) {
        temp_arr[i] = -1;
        for (int ind = temp_arr[i-1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
            if (str[ind] == str[i-1]) {
                temp_arr[i] = ind + 1;
            } else if (ind == 0) {
                temp_arr[i] = 0;
            }
        }
    }
}

void KMP(const string &text, const string &pattern, int *res) {
    int *temp_arr = new int[sz(pattern) + 1];
    build_failure_function(pattern, temp_arr);
    int i = 0;
    int ind = 0;
    while (i < sz(text)) {
        if (text[i] == pattern[ind]) {
            res[i] = ++ind;
            if (res[i] == sz(pattern)) {
                ind = temp_arr[ind];
            }
            i++;
        } else if (ind == 0) {
            res[i++] = 0;
        } else {
            ind = temp_arr[ind];
        }
    }
    delete [] temp_arr;
}

// Setup
void setup(int value, string name) {
    string name_in = name + ".in";
    string name_out = name + ".out";
    freopen(name_in.c_str(), "r", stdin);
    if (value) {
        freopen(name_out.c_str(), "w", stdout);
    }
}

ll md = 1000003;
ll arr[1001];

int main() {
#ifdef LOCAL_HOST
    setup(0, "input");
#endif
	int n;
	std::cin >> n;
	init(arr);
	arr[0] = 0;
	arr[1] = 3;
	for (int i = 2; i <= 1000; i++) {
		arr[i] = (power<ll>(2LL, i-1, md) * (power<ll>(2LL, i, md) + 1)) % md;
		for (int j = i-1; j >= 0; j--)
			arr[i] = (arr[i] + arr[j] * (i - j)) % md;
	}
	int ret_val = (power<ll>(2LL, 2*n, md) - arr[n] + md) % md;
	std::cout << ret_val << std::endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define    ll    long long int
ll m,n,c,d,i,j,k,l,r,x,t,y,u,a,b;vector<ll> v,w;set<ll> s1;string s,p,q;map<ll,pair<ll,ll> > mp;map<ll,ll> mk;
int main ()
{
cin>>n;
m=n*n;
if(m%2==0) m-=1;
if(n>3){
    m=0;
    for(i=4;i<=n;i++){
      d=i*i;
if(d%2==0) d-=1;
m+=d;
    }
    m+=12;
}
cout<<m;
}

#include <iostream>
using namespace std;
void main () {
    int n;
    cin >> n;
    int res = 1;
    for (int i = 0; i < n-1; ++i)
        res = res*3 % 1000000;
    cout << res;
}

#include <iostream>

using namespace std;

const int big = 1E6;
long long mul(int i)
{
    if (i==0) return 1;
    else
        if ( (i%2)==1) return (mul(i-1)*3)%big;
        else {
            long long  k=mul(i/2)%big;
        return k*k;
        };
}

int main()
{
    //int n=10;
    //for(int i=1;i<n;++i)
    int n ; cin>>n;
    cout<<mul(n-1)<<endl;
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<queue>
#include<list>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define INF 2000000000
#define MOD 1000006
int n,k,i,j,m,h,col=0;

long long f(long long x){
	if(x==1)return 1;
	if(x==2)return 3;
	if(x==3)return 9;
	long long t=f(x-1)*3;
	while(t>MOD)t-=MOD;
	return t;
}
int main(){
			//freopen("input.txt","r",stdin);
cin>>n;
cout<<f(n);
return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
int a[4000];
using namespace std;
int main()
{
a[1]=1;
a[2]=3;
for(int i=3;i<2000;i++)
{
    a[i]=a[i-1]*3;
}
int n=0;
cin >> n;
  cout << a[n];
return 0;
}

#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#define endl  "\n"
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
using namespace std;
int main()
{
	int n;
	cin >> n;
	int mod = 1e6+3;
	cout << (ll int)(pow(3,n-1))%mod;
}

#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if ( n==0)
         cout << 1 << endl;
       else {
    cout <<(int) pow(3.0,(float)n-1)<< endl;
}
  //  system("pause");
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    input();
   ll m=pow(10,6)+3;
   ll n;
   cin>>n;
   ll dp[n+1]={};
   dp[0]=dp[1]=1;
   rep(i,2,n+1)
   {
   		dp[i]=3*dp[i-1];
   		dp[i]%m;

   }
   cout<<dp[n]<<endl;
 }

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        long long sum=1,i;
        if(n==0||n==1)
            printf("%d\n",n);
        else
        {
            if(n==2)
                printf("3\n");
            else
            {
                for(i=1;i<n;i++)
                  sum= (sum * 3) % 1000003;
                printf("%I64d\n",sum);
            }
        }

    }
    return 0;
}

//#include <complex>
#include <iostream>
//#include <stdio.h>
#include <vector>
//#include <stack>
#include <algorithm>
//#include <iomanip>
//#include <math.h>

using namespace std;
//
//typedef long long mytype;
//typedef complex<mytype> point;
//
//#define Y imag()
//#define X real()
//#define polar(r,t) ((r)*exp(point(0,(t))))
//#define rgth(a) hypot((a).X,(a).Y)
//#define vec(a,b) ((b)-(a))
//#define dot(a,b) (((a)*conj(b)).X)
//#define rgthsqr(a) dot(a,a)
//#define EPS 1e-12
//
//int gcd(int a,int b)
//{
//  return (b==0 ? a : gcd(b,a%b));
//}

//
//int cost (vector<int> nums,int n)
//{
//
//  int cost = 0 ,sum = 0;
//  while(n>1)
//  {
//      sum = nums[0]+nums[1];
//      cost += sum;
//      nums.erase(nums.begin());
//      n--;
//      for(int i = 1 ; i<n ;i++)
//      if(nums[i]>=sum)
//      {
//          nums[i-1] = sum;
//          break;
//      }
//      else
//      {
//          nums[i-1] = nums[i];
//          if(i == n-1)
//              {
//                  nums[i] = sum;
//                          break;
//              }
//      }
//  }
//  return cost;
//}
int main() {

//  int n ;
//  char curr[200];
//  scanf("%d",&n);
//  getchar();
//  while(n--)
//  {
//      gets(curr);
//      if(curr[0]=='\0')
//          printf("Yes");
//      else
//      {
//      stack<char> s;
//      s.push(curr[0]);
//      int i = 1;
//      while(curr[i]!='\0')
//      {
//          if((s.top() =='(' && curr[i]==')')||(s.top() == '[' && curr[i] == ']'))
//          {
//              s.pop();
//              if(s.empty()&& curr[i+1]!='\0')
//                  s.push(curr[++i]);
//          }
//          else
//              s.push(curr[i]);
//          ++i;
//
//      }
//
//      if(s.empty())
//          printf("Yes");
//      else
//          printf("No");
//      }
//      printf("\n");
//  }

//  int n;
//  while (scanf("%d",&n) && n)
//  {
//      int a;
//      cin >> a;
//      double x,y;
//      int m;
//      long long s = a*10000000;
//      m = 0;
//      point A(0,0);
//      point b(0,s);
//      point c(s,0);
//      point d(s,s);
//      for( int i = 0;i<n;++i)
//      {
//          scanf("%lf %lf",&x,&y);
//
//          int xx = x*10000000;
//          int yy = y*10000000;
//          point given(xx,yy);
//          long long l1,l2,l3,l4;
//          l1 = rgth(vec(A,given));
//          l2 = rgth(vec(b,given));
//          l3 = rgth(vec(c,given));
//          l4 = rgth(vec(d,given));
//
//          if(  s-l1 > -EPS&& s-l2 >-EPS && s-l3 >-EPS && s-14 >-EPS )
//              m++;
//      }
//  double area =m*(a*a)/(double)n;
//  printf("%.5lf\n",area) ;
//  }

//int n;
//while(cin >> n && n )
//{
//  vector<int> nums;
//  int sz = n;
//  while(n--)
//  {
//      int a;
//      cin >> a;
//      nums.push_back(a);
//  }
//
//  int count = 0 ;
//
//  for( int i = 0 ; i < sz-1 ; ++i)
//      for(int  j = i+1 ; j <sz ;++j)
//      {
//          int minn = min(nums[i],nums[j]);
//          int maxx = max(nums[j],nums[i]);
//          if(gcd(minn,maxx)==1)
//              count++;
//      }
//
//if(count == 0)
//  cout <<"No estimate for this data set."<< endl;
//else
//{
//  int pairs = (sz*(sz-1))/2;
//  double pi = sqrt((double)(6*pairs)/count);
//  cout << fixed << setprecision(6)<< pi << endl;
//}
//
//}

    long long n,M,r,mod ;
    M = 1000003;
    while(cin >> n && n)
    {
        r =3;
        mod = 1;
        n-=1;
                while (n > 0)
                {
                    if (n % 2 == 1)
                       mod = (mod * r) % M;
                    n = n >> 1;
                    r = (r * r) % M;
                }

        cout << (mod)<< endl;
    }

//  int n,num,i,j,k,check,a;
//  scanf("%d",&n);
//  while(n--)
//  {
//      scanf("%d",&num);
//       check = 1;
//
//      a  = sqrt(num);
//      for( i = a ; check &&i > a-2 ;i--)
//          for(j = i ; check && j > -1 ; j--)
//              for(k = j;check && k>-1;k--)
//              if(i*i+j*j+k*k == num)
//              {
//                  printf("%d %d %d",k,j,i);
//                  check = 0;
//              }
//
////        bool check = true;
////        for(int i = 0 ;check && i*i < num+1 ;++i)
////            for(int j = i ;  check && j*j < num-i*i+1 ; ++j )
////                for(int k = j ;check && k*k < num-i*i-j*j+1 ;++k)
////                {
////                    if((i*i + j*j + k*k) == num)
////                    {
////                        cout << i <<' '<<j<<' '<<k ;
////                        check = false;
////                    }
////                }
//      if(check)
//          printf("-1");
//      printf("\n");
//  }

//  long long n;
//  while (cin >> n && !cin.eof())
//  {
//      long long sum = 0;
//      for( long long  i = n; i > 0 ; i-=2)
//      {
//          sum+=i;
//      }
//      sum*=2;
//      sum-=1;
//
//      long long summ = 0 ;
//      for(int i = 0 ; i < 3;i++)
//      {
//          summ += sum;
//          sum-=2;
//      }
//      cout << summ << endl;
//  }

//
//int n;
//while(cin >> n && n)
//{
//  vector<int> nums;
//  int a;
//  for(int i = 0 ; i < n ; ++i)
//  {
//      cin >> a;
//      nums.push_back(a);
//  }
//
//  sort(nums.begin(),nums.end());
//  int costs;
//  costs = cost(nums,n);
//  cout << costs << endl;
//}

//  char c;
//  int mod;
//  mod = 0;
//  while(cin >> c&&!cin.eof())
//  {
//      if(c == '1')
//      mod = (((mod%131071)*2)%131071 + 1)%131071;
//      else if(c == '0')
//      mod = (((mod%131071)*2)%131071);
//      else
//      {
//          if(mod)
//                  cout << "NO";
//              else
//                  cout << "YES";
//              cout << endl;
//
//              mod = 0;
//      }
//  }
//

//  int t;
//  cin >> t;
//  while(t--)
//  {
//      int a,b,c;
//      cin >> a >>b >>c;
//
//      bool check = a>0 && b>0 && c>0 && a+b > c && a+c >b && b+c >a;
//      cout << (check ? "OK" : "Wrong!!" )<< endl;
//  }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll;
typedef long double ld;
 int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>> n;
    vector <int> v(n+1,0);
    v[1] = 1;
    for(int i = 2 ; i < n+1 ; i++)
	{	v[i] = 3*v[i-1]; v[i] %= 1000003;	}
	cout<<v[n];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define Sort(v)         sort(v.begin(), v.end(), sortbysec)
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define leftzeros(x)    __builtin_clzll(x)
#define rightzeros(x)   __builtin_ctzll(x)
#define mod           	1e9+7
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;int a[n];for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{	return (a.second < b.second);
	// sorted by 2nd element in ascending order
}
void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	int n; cin >> n;
	if (n == 1) cout << 0;
	else {
		int x = pow(3, n - 1) ;
		cout << x % 1000003;
	}
	return 0;
}

#include<stdio.h>
int main(){
	int m,n,e=1,j;
	scanf("%d",&m);
	for(j=1;j<=m-1;j++)
		e*=m;
	printf("%d",e);
	return 0;}

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <bitset>
#include <list>
#include <iterator>
#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mp make_pair

#pragma comment(linker, "/STACK:64000000")

const int MAXN = 1001;
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-8;

struct Point
{
    int x,y;
    Point(int _x = 0, int _y = 0):
    x(_x),
    y(_y)
    {}
    void Read()
    {
        cin >> x >> y;
    }
};

long long dp[1001];

long long f(int n)
{
    if(dp[n]!=-1)
    {
        return dp[n];
    }
    if(n==1)
    {
        return 1;
    }

    return (dp[n] = 3*f(n-1));
}

int main()
{
    fill(dp, dp+1001, -1);
    int n;
    cin >> n;

    cout << f(n) << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    cout << (int)pow(3.0f, float(n-1)) % (int)(1E6+3) << endl;
    return 0;
}

#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdlib>
#include<cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;

	cout << pow(3,n-1) << endl;

	return 0;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<vector>
#include <iterator>
#include <set>
#include <stack>

#define mx(ans, cnt) ans = max(ans, cnt)
#define fauto(a) for(auto i : a) cout << i << " "; cout << endl;
#define sp(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define _ << " " <<
#define swp(x, y) if (x > y) swap(x, y);
#define swpg(x, y) if (x < y) swap(x, y);
#define ff first

#define ss second
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define nn end1
#define intmax ((1ll << 32) - 1)

#define PI 3.1415926536
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using ull = unsigned long long;

//while (l < r) {
//    int mid = (r + l + 1) / 2;      правый
//    if (a[mid] > x) r = mid - 1;
//    else l = mid;
//}
//while (l < r) {
//    int mid = (r + l) / 2;          левый
//    if (a[mid] >= x) r = mid;
//    else l = mid + 1;
//}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //setlocale(LC_ALL, "Russian");

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    if (!n) {
        cout << 0 << endl;
        return 0;
    }

    n--;

    int ans = 1;

    for (int i = 0; i < n; i++)
        ans = ans * 3 % 1000006;

    cout << ans << endl;

#ifdef LOCAL_DEBUG
    cerr << "Execution time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

/*
 ╔═════════════════════════════════════════════════════════════════════════════════════════╗
 ║                                                                                ║
 ║  ║███████║  ║█████║    ║████║   ║██████║      ║████║ ║██║  ║██║ ║██║    ║██║   ║█████║  ║
 ║  ║██║     ║██║       ║██║  ║██║ ║██║  ║██║  ║██║║██║ ║██║║██║   ║██║    ║██║ ║██║       ║
 ║  ║████║  ║██║  ║███║ ║██║  ║██║ ║███║║██║  ║██║ ║██║ ║████║     ║██║    ║██║   ║████║   ║
 ║  ║██║    ║██║   ║██║ ║██║  ║██║ ║██║██║   ║█████████║║██║║██║    ║██║  ║██║        ║██║ ║
 ║  ║███████║ ║██████║    ║████║   ║██║ ║██║       ║██║ ║██║  ║██║    ║████║     ║█████║   ║
 ║                                                                                ║
 ╚═════════════════════════════════════════════════════════════════════════════════════════╝
 */

/*
 n!

    n!
 --------
 (n - k)!

      n!
 ------------
 k! * (n - k)!
 (я школьник)
 */

#include<bits/stdc++.h>
using namespace std;
int mod=1000000+3;
long long powr(int n)
{
    if(n==0)
        return 1;
    if(n==1)
        return 3;
    if(n%2==1)
        return 3*powr(n/2);
    else
        return (powr(n/2)*powr(n/2))%mod;
}
int main()
{
    int n;
    cin>>n;
    if(n==0||n==1)
    {
        cout<<0;
        return 0;
    }
    long long ans=powr(n-1);
    cout<<ans<<endl;
    return 0;

}

#include <algorithm>
#include <assert.h>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <unistd.h>
#include <map>
#include <math.h>
#include <memory.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <pthread.h> // for std::setprecision()

using namespace std;

typedef int_fast64_t Li;
typedef int_fast32_t ll;
typedef int_fast8_t ii;
typedef long long LL;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL, LL> PII;
typedef vector<PII> VPII;

#define arjun main()
#define FOR(i, x, y) for (LL i = (x); i < (y); ++i)
#define sd(x) scanf("%lld", &x)
#define p(e) printf("\n");

#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

bool visited[100001] = {0};
int color[100001];
std::vector<LL> v[100001];
LL ar = 0;
LL pa = 0;
// C++ program to find out whether a given graph is Bipartite or not
bool bfs(std::vector<LL> *G, LL src, LL V) {
  std::vector<LL>::iterator it;
  // Assign first color to source
  color[src] = 1;
  ar++;
  visited[src] = true;
  // Create a queue (FIFO) of vertex numbers and enqueue source vertex
  // for BFS traversal
  queue<LL> q;
  q.push(src);

  // Run while there are vertices in queue (Similar to BFS)
  while (!q.empty()) {
    // Dequeue a vertex from queue ( Refer http://goo.gl/35oz8 )
    LL u = q.front();
    q.pop();
    visited[u] = true;
    // Find all non-colored adjacent vertices
    for (it = G[u].begin(); it != G[u].end(); ++it) {
      // An edge from u to v exists and destination v is not colored
    }
  }

  // If we reach here, then all adjacent vertices can be colored with
  // alternate color
  return true;
}

LL findgcd(LL a, LL b) {
  if (b == 0)
    return a;
  return findgcd(b, a % b);
}

LL hasFound[256] = {0};

LL minWindow(const char *S, LL n, LL n2) {
  LL minWindowLen = INT_MAX;
  LL count = 0;
  for (LL begin = 0, end = 0; end < n; end++) {
    hasFound[(int)S[end]]++;
    if (hasFound[(int)S[end]] <= 1)
      count++;

    // if window constraint is satisfied
    if (count == n2) {
      // advance begin index as far right as possible,
      // stop when advancing breaks window constraint.
      while (hasFound[(int)S[begin]] > 1) {
        if (hasFound[(int)S[begin]] > 1)
          hasFound[(int)S[begin]]--;
        begin++;
      }

      // update minWindow if a minimum length is met
      LL windowLen = ((end - begin) + 1);
      if (windowLen < minWindowLen) {
        minWindowLen = windowLen;
      } // end if
    }   // end if
  }     // end for

  return minWindowLen;
}
template <typename T> T maxm(T a, T b) { return (a > b) ? a : b; }
template <typename T> T minm(T a, T b) { return (a < b) ? a : b; }

LL nextNearestPowOf2(LL n)
{
    LL x = n;
    n--;           // 1000 0011 --> 1000 0010
    n |= n >> 1;   // 1000 0010 | 0100 0001 = 1100 0011
    n |= n >> 2;   // 1100 0011 | 0011 0000 = 1111 0011
    n |= n >> 4;   // 1111 0011 | 0000 1111 = 1111 1111
    n |= n >> 8;   // ... (At this point all bits are 1, so further bitwise-or
    n |= n >> 16;  //      operations produce no effect.)
    n++;
    if(x!=n)
    return n;
    else return 2*n;
}

LL factorial(LL n)
{
  if(n==1 || n==0) return 1;
  else return n*factorial(n-1);
}

LL nCx(LL n,LL x)
{
  LL a = factorial(n);
  LL b = factorial(x);
  LL c = factorial(n-x);
  return a/(b*c);
}

/**
 * program for sorting an array in descending order
 * end here is the number of elements not the index
 */

LL *sort_descending(LL *array, LL start, LL end) {
  sort(array + start, array + end + 1, std::greater<LL>());
  return array;
}

int main() {
    fast;
    LL t;
    LL n;
    cin>>n;
    cout<<(LL)pow(3,n-1)<<endl;
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <math.h>
using namespace std;
long long pow2(long long a,long long b){
   long long ans=1;
   for(long long i=1;i<=b;i++)
      ans*=a;
   return ans;
}
long long n,truoc;
int main(){
   cin>>n;
   cout<<pow2(3,n-1)%1000003;

}

#include<stdio.h>
#include<math.h>
int main()
{
    int N;
    scanf("%d",&N);
    printf("%.0f",pow(3,N-1));
    return 0;
}

#include <stdio.h>
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cassert>
#include <string.h>
#include <windows.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")

typedef vector<int> vi;
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()

string problem_name = "a";

void init(){
  freopen((problem_name+".in").c_str(),"rt",stdin);
//  freopen((problem_name+".out").c_str(),"wt",stdout);
}
int res[1111];
int m=1000006;
int calc(int n)
{
    if (n==0) return 0;
    if (n==1) return 1;
    int res = calc(n-1)*3;
    res%=m;
    return res;
}

int main()
{
//  init();

    int n;
    scanf("%d",&n);
    printf("%d\n",calc(n));

 // return 0;
}

#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);

	long long int ans = 1;
	for(int i = 1; i < N; ++i)
		ans = (ans*3)%1000003;

	printf("%lld\n", (N)?ans%1000003:0);
	return 0;
}

#include<bits/stdc++.h>
#include<string.h>

using namespace std;

int main()
{
    int n;
    cin>>n;

    long long int ans=pow(3,n-1);
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000003
int main(){
	long n,temp=1;
	cin>>n;
	if(n==0){
		cout<<"0";return 0;
	}else{
		temp=1;
		for(int i=1;i<n;i++){
			temp= (temp*3)%mod;
		}
	}
	cout<<temp%mod;return 0;
}

    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
    int main()
    {

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

       int n;

       cin>>n;

       ll h=1;

       n--;

       while(n--) {
        h = (h*3)%(mod);
       }

       cout<<h;

        return 0;
    }

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("tabs.in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long n,t=1;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        t*=3%1000003;
    }
    cout<<t;
}

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <map>
#include <cmath>
#include <string>

using namespace std;

char key[] = "AEIOUYaeiouy";

int DotProduct (int x, int y, int x1, int y1, int x2, int y2)
{
    return ((x1-x)*(x2-x1) + (y1-y)*(y2-y1));
}

double Distance (int x, int y, int x1, int y1)
{
    return sqrt (double((x1-x)*(x1-x) + (y1-y)*(y1-y)));
}

inline int max (int a, int b)
{
    return (a>b)?a:b;
}

bool isVowel (string str)
{
    size_t f = str.find('?');
    f --;
    while (!isalpha(str.at(f)))
        f --;
    for (int i = 0; i < sizeof(key); i ++)
    {
        if (str.at(f) != key[i]);
        else return 1;
    }
    return 0;
}

int main()
{
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    long int n; cin >> n;
    long long int pr = 1;
    for (int i = 0; i < n-1; i ++)
        pr *= 3;
    cout << pr << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define MOD 1000003

int rec(int n) {
	if(n < 1) return 1;
	return (3*rec(n-1))%MOD;
}

int main() {
	int n;
	cin >> n;
	cout << rec(n);

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

int main() {
    int n;
    unsigned long m;
    cin >> n;
    m = (unsigned long )pow(3,n - 1);
        cout << m % (int)(pow(10,6) + 3);
}

#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stdio.h>
#include <sstream>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>

using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
#define sz(v) (int) v.size()
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define foreach(i,c) for(__typeof((c).begin()) i = (c).begin() ; i != (c).end() ; i++)

int main() {
    // freopen("input.in", "rt", stdin);
    // freopen("out.out", "wt", stdout);
    vector<long long> v(1001);
    v[0] = 0;
    v[1] = 1;
    FOR(i, 2, 1001) {
        v[i] = (v[i - 1] * 3)%1000003;
    }
    int n;
    cin >> n;
    cout << v[n] % 1000003<< endl;
    return 0;
}

#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <stack>
using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FORSET(z,s) for(z=s.begin();z!=s.end;z++)
#define sqr(x) (x*x)

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
const double inf1 = 1e-9;
const int p = 1000003;

void main()
{
    int n;
    cin>>n;
    int sum = n;
    int k = 3;
    FOR(i,n-1)
    {
        sum*=k;
        sum%=p;
    }
    cout<<sum;
    cin.get();
    cin.get();
    return;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long int

int main()
{
    ll n;
    cin>>n;

    if(n==0)    cout<<0;
    else cout<<(ll)powl(3,n-1)%1000003;
	return 0;
}

/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000007
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;

int pwr(int base,int exp){
	if(exp==0)
		return 1;
	if(exp==1)
		return base;
	int res=(1LL*base*base)%MOD;
	return (1LL*pwr(res,exp>>1)*pwr(base,exp&1))%MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<pwr(3,n-1);
	return 0;
}