#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

int main()
{
ll i,j,k,n,t,x,actual,y;
cin>>n;
vector<vector<ll> > num(n+1);
vector<vector<ll> > inv(n+1);
vector<ll> tam(n+1);
vector<bool> verdad(n+1,0);
vector<ll> lista;
deque<ll> aux;
cin>>t;

for(i=0;i<t;i++)
{
 cin>>x;
 lista.pb(x);
}

for(i=1;i<=n;i++)
{
 cin>>k;
 tam[i]=k;
 if(k==0) aux.pb(i);
 for(j=0;j<k;j++)
 {
  cin>>x;
  num[i].pb(x);
  inv[x].pb(i);
 }
}
vector<ll> copia(tam);
 while(aux.size()!=0)
 {
  x=aux.at(0);
  aux.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   tam[y]-=1;
   if(tam[y]==0) aux.pb(y);
  }
 }

for(j=0;j<lista.size();j++)
{
 if(tam[lista[j]]!=0)
 {
  cout<<"-1";
  return 0;
 }
}

vector<ll> pila;
vector<ll> mov;
deque<ll> cola;
deque<ll> ayuda;
set<ll> triste;

for(i=0;i<lista.size();i++)
{
 x=lista[i];
 if(!verdad[x])
 {
  cola.pb(x);
  verdad[x]=1;
  while(cola.size()!=0)
  {
   actual=cola.at(0);
   triste.insert(actual);
   if(copia[actual]==0) ayuda.pb(actual);
   cola.pop_front();
   for(j=0;j<num[actual].size();j++)
   {
    y=num[actual][j];
    if(!verdad[y])
    {
     cola.pb(y);
     verdad[y]=1;
    }
   }
  }

 while(ayuda.size()!=0)
 {
  x=ayuda.at(0);
  if(triste.find(x)!=triste.end())mov.pb(x);
  ayuda.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   copia[y]-=1;
   if(copia[y]==0) ayuda.pb(y);
  }
 }

 triste.clear();
 pila.insert(pila.begin(), mov.rbegin(), mov.rend()); // :c
 mov.clear();
 }
}

cout<<pila.size()<<endl;
for(auto itr=pila.rbegin();itr!=pila.rend()-1;itr++)
{
 cout<<*itr<<" ";
}
cout<<pila[0];

return 0;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

int main()
{
ll i,j,k,n,t,x,actual,y;
cin>>n;
vector<vector<ll> > num(n+1);
vector<vector<ll> > inv(n+1);
vector<ll> tam(n+1);
vector<bool> verdad(n+1,0);
vector<ll> lista;
deque<ll> aux;
cin>>t;

for(i=0;i<t;i++)
{
 cin>>x;
 lista.pb(x);
}

for(i=1;i<=n;i++)
{
 cin>>k;
 tam[i]=k;
 if(k==0) aux.pb(i);
 for(j=0;j<k;j++)
 {
  cin>>x;
  num[i].pb(x);
  inv[x].pb(i);
 }
}

 while(aux.size()!=0)
 {
  x=aux.at(0);
  aux.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   tam[y]-=1;
   if(tam[y]==0) aux.pb(y);
  }
 }

for(j=0;j<lista.size();j++)
{
 if(tam[lista[j]]!=0)
 {
  cout<<"-1";
  return 0;
 }
}

vector<ll> pila;
vector<ll> mov;
deque<ll> cola;
for(i=0;i<lista.size();i++)
{
 x=lista[i];
 if(!verdad[x])
 {
  cola.pb(x);
  verdad[x]=1;
  while(cola.size()!=0)
  {
   actual=cola.at(0);
   mov.pb(actual);
   cola.pop_front();
   for(j=0;j<num[actual].size();j++)
   {
    y=num[actual][j];
    if(!verdad[y])
    {
     cola.pb(y);
     verdad[y]=1;
    }
   }
  }
 }
 pila.insert(pila.begin(), mov.begin(), mov.end()); // :c
 mov.clear();
}

cout<<pila.size()<<endl;
for(auto itr=pila.rbegin();itr!=pila.rend()-1;itr++)
{
 cout<<*itr<<" ";
}
cout<<pila[0];

return 0;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

int main()
{
ll i,j,k,n,t,x,actual,y;
cin>>n;
vector<vector<ll> > num(n+1);
vector<vector<ll> > inv(n+1);
vector<ll> tam(n+1);
vector<bool> verdad(n+1,0);
vector<ll> lista;
deque<ll> aux;
cin>>t;

for(i=0;i<t;i++)
{
 cin>>x;
 lista.pb(x);
}

for(i=1;i<=n;i++)
{
 cin>>k;
 tam[i]=k;
 if(k==0) aux.pb(i);
 for(j=0;j<k;j++)
 {
  cin>>x;
  num[i].pb(x);
  inv[x].pb(i);
 }
}

 while(aux.size()!=0)
 {
  x=aux.at(0);
  aux.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   tam[y]-=1;
   if(tam[y]==0) aux.pb(y);
  }
 }

for(j=0;j<lista.size();j++)
{
 if(tam[lista[j]]!=0)
 {
  cout<<"-1";
  return 0;
 }
}

vector<ll> pila;
deque<ll> cola;
for(i=0;i<lista.size();i++)
{
 x=lista[i];
 if(!verdad[x])
 {
  cola.pb(x);
  while(cola.size()!=0)
  {
   actual=cola.at(0);
   verdad[actual]=1;
   pila.pb(actual);
   cola.pop_front();
   for(j=0;j<num[actual].size();j++)
   {
    y=num[actual][j];
    if(!verdad[y])
    {
     cola.pb(y);
    }
   }
  }
 }
}

cout<<pila.size()<<endl;
for(auto itr=pila.rbegin();itr!=pila.rend()-1;itr++)
{
 cout<<*itr<<" ";
}
cout<<pila[0];

return 0;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

void back(vector<vector<ll> > &num,vector<bool> &verdad,vector<ll> &mov,vector<ll> &copia, ll x,ll pred)
{
 ll i,y;
 if (copia[x]==0)
 {
  copia[pred]-=1;
  mov.pb(x);
  verdad[x]=1;
  return ;
 }

 for(i=0;i<num[x].size();i++)
 {
  y=num[x][i];
  if(!verdad[y])
  {
   back(num,verdad,mov,copia,y,x);
  }
  else
  {
   copia[x]-=1;
  }
 }

 if(copia[x]==0)
 	{
 	 mov.pb(x);
     verdad[x]=1;
     copia[pred]-=1;
 	}
}

int main()  //Grafos con ciclos + backtracking
{
ll i,j,k,n,t,x,actual,y;
cin>>n;
vector<vector<ll> > num(n+1);
vector<vector<ll> > inv(n+1);
vector<ll> tam(n+1);
vector<ll>copia;
vector<bool> verdad(n+1,0);
vector<ll> lista;
deque<ll> aux;
cin>>t;

for(i=0;i<t;i++)
{
 cin>>x;
 lista.pb(x);
}

for(i=1;i<=n;i++)
{
 cin>>k;
 tam[i]=k;
 if(k==0) aux.pb(i);
 for(j=0;j<k;j++)
 {
  cin>>x;
  num[i].pb(x);
  inv[x].pb(i);
 }
}
copia=tam;

 while(aux.size()!=0)
 {
  x=aux.at(0);
  aux.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   tam[y]-=1;
   if(tam[y]==0) aux.pb(y);
  }
 }

for(j=0;j<lista.size();j++)
{
 if(tam[lista[j]]!=0)
 {
  cout<<"-1";
  return 0;
 }
}

vector<ll> mov;

for(i=0;i<lista.size();i++)
{
 if(!verdad[lista[i]])
 {
  back(num,verdad,mov,copia,lista[i],0);
 }
}

cout<<mov.size()<<endl;
for(i=0;i<mov.size()-1;i++)
{
 cout<<mov[i]<<" ";
}
cout<<mov[mov.size()-1];
return 0;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

void back(vector<vector<ll> > &num,vector<bool> &verdad,vector<ll> &mov,vector<ll> &copia, ll x,ll pred)
{
 ll i,y;
 if (copia[x]==0)
 {
  copia[pred]-=1;
  mov.pb(x);
  verdad[x]=1;
  return ;
 }

 for(i=0;i<num[x].size();i++)
 {
  y=num[x][i];
  if(!verdad[y])
  {
   back(num,verdad,mov,copia,y,x);
  }
  else
  {
   copia[x]-=1;
  }
 }

 if(copia[x]==0)
 	{
 	 mov.pb(x);
     verdad[x]=1;
     copia[pred]-=1;
 	}
}

int main()
{
ll i,j,k,n,t,x,actual,y;
cin>>n;
vector<vector<ll> > num(n+1);
vector<vector<ll> > inv(n+1);
vector<ll> tam(n+1);
vector<ll>copia;
vector<bool> verdad(n+1,0);
vector<ll> lista;
deque<ll> aux;
cin>>t;

for(i=0;i<t;i++)
{
 cin>>x;
 lista.pb(x);
}

for(i=1;i<=n;i++)
{
 cin>>k;
 tam[i]=k;
 if(k==0) aux.pb(i);
 for(j=0;j<k;j++)
 {
  cin>>x;
  num[i].pb(x);
  inv[x].pb(i);
 }
}
copia=tam;
 while(aux.size()!=0)
 {
  x=aux.at(0);
  aux.pop_front();
  for(j=0;j<inv[x].size();j++)
  {
   y=inv[x][j];
   tam[y]-=1;
   if(tam[y]==0) aux.pb(y);
  }
 }

for(j=0;j<lista.size();j++)
{
 if(tam[lista[j]]!=0)
 {
  cout<<"-1";
  return 0;
 }
}

vector<ll> mov;
vector<ll> pila;

for(i=0;i<lista.size();i++)
{
 if(!verdad[lista[i]])
 {
  back(num,verdad,mov,copia,lista[i],0);
  pila.insert(pila.end(),mov.begin(),mov.end());
  mov.clear();
 }
}

cout<<pila.size()<<endl;
for(i=0;i<pila.size()-1;i++)
{
 cout<<pila[i]<<" ";
}
cout<<pila[pila.size()-1];
return 0;
}


#include <bits/stdc++.h>
#define ill int long long
#define pb push_back
#define mp make_pair
#define fi first
#define ld long double
#define se second
using namespace std;
int n,k,i,j,b[100005],me[100005];
vector <int> my[100005],ans;
bool used[100005];
void dfs(int x)
{
    used[x]=true;
    int h=0;
    for (int j=0;j<my[x].size();j++)
    {
        if (used[my[x][j]]==0)dfs(my[x][j]);
        if (me[my[x][j]]==1)h++;
    }
    if (h==my[x].size()){me[x]=1;}
    if (me[x]==1)ans.pb(x);
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;i++)
    {
        cin>>b[i];
    }
    for (i=1;i<=n;i++)
    {
        int x,y;
        cin>>x;
            for (j=1;j<=x;j++)
            {
                cin>>y;
                my[i].pb(y);
            }
    }
    for (i=1;i<=k;i++)
    {
        if (me[b[i]]==0 && used[b[i]]==1){cout<<-1;return 0;}
        if (me[b[i]]==0 && used[b[i]]==0)dfs(b[i]);
    }
    cout<<ans.size()<<endl;
    for (i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }

}


#include <bits/stdc++.h>
#define ill int long long
#define pb push_back
#define mp make_pair
#define fi first
#define ld long double
#define se second
using namespace std;
int n,k,i,j,b[100005],me[100005];
vector <int> my[100005],ans;
bool used[100005];
void dfs(int x)
{
    used[x]=true;
    int h=0;
    for (int j=0;j<my[x].size();j++)
    {
        if (used[my[x][j]]==0)dfs(my[x][j]);
        if (me[my[x][j]]==1)h++;
    }
    if (h==my[x].size()){me[x]=1;ans.pb(x);}
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;i++)
    {
        cin>>b[i];
    }
    for (i=1;i<=n;i++)
    {
        int x,y;
        cin>>x;
            for (j=1;j<=x;j++)
            {
                cin>>y;
                my[i].pb(y);
            }
    }
    for (i=1;i<=k;i++)
    {
        if (used[b[i]]==0)dfs(b[i]);
        if (me[b[i]]==0){cout<<-1;return 0;}
    }
    cout<<ans.size()<<endl;
    for (i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }

}


#include <bits/stdc++.h>
#define ill int long long
#define pb push_back
#define mp make_pair
#define fi first
#define ld long double
#define se second
using namespace std;
ill n,k,i,j,b[200005],me[200005];
vector <ill> my[200005],ans;
bool used[200005];
void dfs(ill x)
{
    used[x]=true;
    ill h=0;
    for (int j=0;j<my[x].size();j++)
    {
        if (used[my[x][j]]==0)dfs(my[x][j]);
        if (me[my[x][j]]==1)h++;
    }
    if (h==my[x].size()){me[x]=1;}
    if (me[x]==1)ans.pb(x);
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;i++)
    {
        cin>>b[i];
    }
    for (i=1;i<=n;i++)
    {
        int x,y;
        cin>>x;
            for (j=1;j<=x;j++)
            {
                cin>>y;
                my[i].pb(y);
            }
    }
    for (i=1;i<=k;i++)
    {
        if (me[b[i]]==0 && used[b[i]]==1){cout<<-1;return 0;}
        if (me[b[i]]==0 && used[b[i]]==0)dfs(b[i]);
    }
    cout<<ans.size()<<endl;
    for (i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }

}


#include <bits/stdc++.h>
#define ill int long long
#define pb push_back
#define mp make_pair
#define fi first
#define ld long double
#define se second
using namespace std;
int n,k,i,j,b[100005],me[100005],c[100005];
vector <int> my[100005],ans;
bool used[100005];
void dfs(int x)
{
    used[x]=true;
    int h=0;
    for (int j=0;j<my[x].size();j++)
    {
        if (used[my[x][j]]==0)dfs(my[x][j]);
        if (me[my[x][j]]==1)h++;
    }
    if (h==my[x].size()){me[x]=1;}
    if (me[x]==1 && c[x]==0){ans.pb(x);c[x]=1;}
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;i++)
    {
        cin>>b[i];
    }
    for (i=1;i<=n;i++)
    {
        int x,y;
        cin>>x;
        if (x==0){me[x]=1;used[x]=true;}
            for (j=1;j<=x;j++)
            {
                cin>>y;
                my[i].pb(y);
            }
    }
    for (i=1;i<=k;i++)
    {
        if (me[b[i]]==0 && used[b[i]]==1){cout<<-1;return 0;}
        if (me[b[i]]==0 && used[b[i]]==0)dfs(b[i]);
    }
    cout<<ans.size()<<endl;
    for (i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }

}


#include<stdio.h>

typedef long long ll;

const ll PREC=100000000;

int main() {
  double aa,dd;
  scanf("%lf%lf", &aa, &dd);
  ll a = (ll)(aa*PREC);
  ll d = (ll)(dd*PREC);
  //printf("%I64d %I64d\n", a,d);
  int n;
  scanf("%d", &n);
  int strana=0;
  ll p=0;
  for (int i=0; i<n; i++) {
    p+=d;
    strana = (p/a)%4;
    double pp;
    if (strana<2) { pp = (  p%a)/(double)PREC; }
    else          { pp = (a-p%a)/(double)PREC; }
    if (!(strana&1)) {
      printf("%f %f\n", pp, strana ? aa : 0);
    } else {
      printf("%f %f\n", (strana-1) ? 0 : aa, pp);
    }
  }
}


#include<stdio.h>

const int PREC=10000;

int main() {
  double aa,dd;
  scanf("%lf%lf", &aa, &dd);
  int a = (int)((aa+0.00005)*PREC);
  int d = (int)((dd+0.00005)*PREC);
  //printf("%I64d %I64d\n", a,d);
  int n;
  scanf("%d", &n);
  int strana=0;
  int p=0;
  for (int i=0; i<n; i++) {
    p+=d;
    strana = (p/a)%4;
    double pp;
    if (strana<2) { pp = (  p%a)/(double)PREC; }
    else          { pp = (a-p%a)/(double)PREC; }
    if (!(strana&1)) {
      printf("%f %f\n", pp, strana ? aa : 0);
    } else {
      printf("%f %f\n", (strana-1) ? 0 : aa, pp);
    }
  }
}


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

//typedef long long ll;

//const ll PREC=10000;

int main() {
  double a,d;
  scanf("%lf%lf", &a, &d);
  int n;
  scanf("%d", &n);
  int strana=0;
  double p=0;
  for (int i=0; i<n; i++) {
    p+=d;
    strana = fmod(p/a,4);
    double pp;
    if (strana<2) { pp = (  fmod(p,a)); }
    else          { pp = (a-fmod(p,a)); }
    if (!(strana&1)) {
      printf("%lf %lf\n", pp, strana ? a : 0);
    } else {
      printf("%lf %lf\n", (strana-1) ? 0 : a, pp);
    }
  }
}


#include<stdio.h>

const int PREC=100000000;

int main() {
  double aa,dd;
  scanf("%lf%lf", &aa, &dd);
  int a = (int)(aa*PREC);
  int d = (int)(dd*PREC);
  printf("%d %d\n", a,d);
  int n;
  scanf("%d", &n);
  int strana=0;
  int p=0;
  for (int i=0; i<n; i++) {
    p+=d;
    strana = (p/a)%4;
    double pp;
    if (strana<2) { pp = (  p%a)/(double)PREC; }
    else          { pp = (a-p%a)/(double)PREC; }
    if (!(strana&1)) {
      printf("%f %f\n", pp, strana ? aa : 0);
    } else {
      printf("%f %f\n", (strana-1) ? 0 : aa, pp);
    }
  }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (long long )(aa*100000 + 1e-9);
    d = (long long )(dd*100000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = (long long)(d*i)%(a*4);
        if(res <= a) {
            y = 0;
            x = res;
        } else if(res <= a+a) {
            x = a;
            y = res-a;
        } else if(res <= a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res <= a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/100000.,y/100000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (long long )(aa*1000000 + 1e-9);
    d = (long long )(dd*1000000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = (long long)(d*i)%(a*4);
        if(res < a) {
            y = 0;
            x = res;
        } else if(res < a+a) {
            x = a;
            y = res-a;
        } else if(res < a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res < a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/1000000.,y/1000000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (aa*1000000 + 1e-9);
    d = (dd*1000000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = 1ll * (d*i)%(a*4);
        if(res < a) {
            y = 0;
            x = res;
        } else if(res < a+a) {
            x = a;
            y = res-a;
        } else if(res < a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res < a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/1000000.,y/1000000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (long long )(aa*100000 + 1e-9);
    d = (long long )(dd*100000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = (long long)(d*i)%(a*4);
        if(res < a) {
            y = 0;
            x = res;
        } else if(res < a+a) {
            x = a;
            y = res-a;
        } else if(res < a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res < a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/100000.,y/100000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    long double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (aa*10000 + 1e-9);
    d = (dd*10000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = 1ll * (d*i)%(a*4);
        if(res < a) {
            y = 0;
            x = res;
        } else if(res < a+a) {
            x = a;
            y = res-a;
        } else if(res < a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res < a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/10000.,y/10000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (aa*10000 + 1e-9);
    d = (dd*10000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = 1ll * (d*i)%(a*4);
        if(res < a) {
            y = 0;
            x = res;
        } else if(res < a+a) {
            x = a;
            y = res-a;
        } else if(res < a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res < a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/10000.,y/10000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (long long )(aa*1000000 + 1e-9);
    d = (long long )(dd*1000000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = (long long)(d*i)%(a*4);
        if(res <= a) {
            y = 0;
            x = res;
        } else if(res <= a+a) {
            x = a;
            y = res-a;
        } else if(res <= a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res <= a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/1000000.,y/1000000.);
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<memory.h>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<sstream>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define M 1000000007
using namespace std;
typedef pair<int,int> pt;

int main(){
//  freopen("1.in","r",stdin);
//  freopen("1.out","w",stdout);
    long double a1, d1;
    int n;
    cin >> a1 >> d1;
    long long a = a1 * 10000 + 1e-9;
    long long d = d1 * 10000 + 1e-9;

    cin >> n;
    for (int i = 0; i < n; i++) {
        long long x = 1ll * (i + 1) * d % (4 * a);
        long long xx, yy;
        if (x < a) {
            xx = x;
            yy = 0;
        } else if (x < a + a) {
            xx = a;
            yy = x - a;
        } else if (x < a + a + a) {
            xx = a + a + a - x;
            yy = a;
        } else {
            xx = 0;
            yy = a + a + a + a - x;
        }
        printf("%.8lf %.8lf\n", xx / 10000., yy / 10000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    double aa,dd;
    int temp;
    cin>>aa>>dd;
    int n;
    cin>>n;
    long long a,d;
    a = (long long )(aa*10000 + 1e-9);
    d = (long long )(dd*10000 + 1e-9);
    for(int i=1;i<=n;i++) {
        long long x,y;
        long long res = (long long)(d*i)%(a*4);
        if(res <= a) {
            y = 0;
            x = res;
        } else if(res <= a+a) {
            x = a;
            y = res-a;
        } else if(res <= a+a+a) {
            y = a;
            x = a+a+a-res;
        } else if(res <= a+a+a+a) {
            x = 0;
            y = a+a+a+a-res;
        }
        printf("%.8lf %.8lf\n",x/10000.,y/10000.);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
double a,d,n,j,k,aa=0.0;
int i;
int main()
{
    cin>>a>>d>>n;
    for(i=0,k=0;i<n;i++)
    {
        k+=d;
        j=k;//cout<<j<<endl;
        //while(j>4.0*a) j-=4.0*a;
        if(j>4.0*a)
        {
            ll ss=j/(4.0*a);//cout<<ss<<endl;
            double sss=ss*(4.0*a);//cout<<sss<<endl;
            j=j-sss;//cout<<j<<endl;
        }
        if(j<=a) printf("%.10lf 0.0000000000\n",j);
        else if(j>a&&j<=2*a)
            printf("%.10lf %.10lf\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10lf %.10lf\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("0.0000000000 %.10lf\n",a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
double a,d,n,j,k,aa=0.0;
int main()
{
    cin>>a>>d>>n;
    for(k=d; k<=n*d; k+=d)
    {
        j=k;//cout<<j<<endl;
        //while(j>4.0*a) j-=4.0*a;
        if(j>4.0*a)
        {
            int ss=j/(4.0*a);//cout<<ss<<endl;
            double sss=ss*(4.0*a);//cout<<sss<<endl;
            j=j-sss;//cout<<j<<endl;
        }
        double y=j/(4*a);
        if(y<=0.25)
            printf("%.10lf 0.0000000000\n",y*4*a);
        if(y>0.25&&y<=0.5)
            printf("%.10lf %.10lf\n",a,(y-0.25)*4*a);
        if(y>0.5&&y<=0.75)
            printf("%.10lf %.10lf\n",a-(y-0.5)*4*a,a);
        if(y>0.75)
            printf("0.0000000000 %.10lf\n",a-(y-0.75)*4*a);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
int n,i;
double a,d,j,k,aa=0.0;
int main()
{
    scanf("%lf%lf%d",&a,&d,&n);
    for(k=d; k<=n*d; k+=d)
    {
        j=k;
        while(j>4.0*a) j-=4.0*a;
        if(j<=a) printf("%.10f %.10fa\n",j,aa);
        else if(j>a&&j<=2*a)
            printf("%.10f %.10fb\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10f %.10fc\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("%.10f %.10fd\n",aa,a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
double a,d,n,j,k,aa=0.0;
int main()
{
    cin>>a>>d>>n;
    for(k=d; k<=n*d; k+=d)
    {
        j=k;//cout<<j<<endl;
        //while(j>4.0*a) j-=4.0*a;
        if(j>4.0*a)
        {
            int ss=j/(4.0*a);//cout<<ss<<endl;
            double sss=ss*(4.0*a);//cout<<sss<<endl;
            j=j-sss;//cout<<j<<endl;
        }

        if(j<=a) printf("%.10lf 0.0000000000\n",j);
        else if(j>a&&j<=2*a)
            printf("%.10lf %.10lf\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10lf %.10lf\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("0.0000000000 %.10lf\n",a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
typedef long long ll;
double a,d,n,j,k,aa=0.0;
int i;
int main()
{
    cin>>a>>d>>n;
    for(i=0,k=0;i<n;i++)
    {
        k+=d;
        j=k;//cout<<j<<endl;
        //while(j>4.0*a) j-=4.0*a;
        if(j>4.0*a)
        {
            ll ss=j/(4.0*a);//cout<<ss<<endl;
            double sss=ss*(4.0*a);//cout<<sss<<endl;
            j=j-sss;//cout<<j<<endl;
        }
        if(j<=a) printf("%.10lf 0.0000000000\n",j);
        else if(j>a&&j<=2*a)
            printf("%.10lf %.10lf\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10lf %.10lf\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("0.0000000000 %.10lf\n",a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000002
#define MN 305
#define INF 1000000007
using namespace std;
typedef long long ll;
int main()
{
    double x=0,a,d,y;
    int n,i,j;
    scanf("%lf%lf",&a,&d);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        x+=d;
        if(x>4.0*a)
        {
            ll ss=x/(4.0*a);//cout<<ss<<endl;
            double sss=ss*4.0*a;//cout<<sss<<endl;
            x=x-sss;//cout<<j<<endl;
        }
        y=x/(4*a);
        if(y<=0.25)
            printf("%.10lf 0.0000000000\n",y*4*a);
        if(y>0.25&&y<=0.5)
            printf("%.10lf %.10lf\n",a,(y-0.25)*4*a);
        if(y>0.5&&y<=0.75)
            printf("%.10lf %.10lf\n",a-(y-0.5)*4*a,a);
       if(y>0.75)
            printf("0.0000000000 %.10lf\n",a-(y-0.75)*4*a);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
int n,i;
double a,d,j,k,aa=0.0;
int main()
{
    scanf("%lf%lf%d",&a,&d,&n);
    for(k=d; k<=n*d; k+=d)
    {
        j=k;
        while(j>4.0*a) j-=4.0*a;
        if(j<=a) printf("%.10f %.10f\n",j,aa);
        else if(j>a&&j<=2*a)
            printf("%.10f %.10f\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10f %.10f\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("%.10f %.10f\n",aa,a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
double a,d,n,j,k,aa=0.0;
int i;
int main()
{
    cin>>a>>d>>n;
    for(i=0,k=0;i<n;i++)
    {
        k+=d;
        j=k;//cout<<j<<endl;
        //while(j>4.0*a) j-=4.0*a;
        if(j>4.0*a)
        {
            int ss=j/(4.0*a);//cout<<ss<<endl;
            double sss=ss*(4.0*a);//cout<<sss<<endl;
            j=j-sss;//cout<<j<<endl;
        }
        if(j<=a) printf("%.10lf 0.0000000000\n",j);
        else if(j>a&&j<=2*a)
            printf("%.10lf %.10lf\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.10lf %.10lf\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("0.0000000000 %.10lf\n",a-(j-3.0*a));
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define sca(a) scanf("%d",&a)
#define pri(a) printf("%d\n",a)
#define MM 2000005
#define MN 1005
#define INF 10000007
using namespace std;
double a,d,n,j,k,aa=0.0;
int main()
{
    scanf("%lf%lf%lf",&a,&d,&n);
    for(k=d; k<=n*d; k+=d)
    {
        j=k;//cout<<j<<endl;
        while(j>4.0*a) j-=4.0*a;
        if(j<=a) printf("%.12lf %.12lf\n",j,aa);
        else if(j>a&&j<=2*a)
            printf("%.12lf %.12lf\n",a,j-a);
        else if(j>2*a&&j<=3*a)
            printf("%.12lf %.12lf\n",a-(j-2.0*a),a);
        else if(j>3*a&&j<=4*a)
            printf("%.12lf %.12lf\n",aa,a-(j-3.0*a));
    }
    return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10lf %.10lf\n", x, y);
	}
	//system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb>>n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.15lf %.15lf\n",x,y);
	}
	//system("pause");
    return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.15f %.15f\n", x, y);
	}
//	system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb>>n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10lf %.10lf\n",x,y);
	}
	//system("pause");
    return 0;
}


// codeforces.cpp: ������� ���� �������.

//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	long double a, b,x,y,bb;
	long int n, k, l = 1;
	cin >> a >> bb>>n;
	while (bb > a * 4) bb -= a * 4;
	for (int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10lf %.10lf",x,y);
	}
//	system("pause");
    return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10f %.10f\n", x, y);
	}
	//system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb>>n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		cout << x<<" "<< y << endl;
	}
//	system("pause");
    return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10f %.10f\n", x, y);
	}
	//system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 double a, b, x, y, bb;
	 int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10f %.10f\n", x, y);
	}
	//system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 double a, b, x, y, bb;
	 int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for ( int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10f %.10f\n", x, y);
	}
//	system("pause");
	return 0;
}


//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	double a, b, x = 0.0000000, y = 0.0000000, bb;
	 int n, k, l = 1;
	cin >> a >> bb >> n;
	while (bb > a * 4) bb -= a * 4;
	for ( int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
	if (l>1&&l<4)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b >= a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10f %.10f\n", x, y);
	}
//system("pause");
	return 0;
}


codeforces.cpp: ������� ���� �������.

//#include "stdafx.h"
#include "iostream"
#include <algorithm>
#include "stdio.h"

//using namespace System;
using namespace std;
int main()
{
	 long double a, b, x, y, bb;
	long long int n, k, l = 1;
	cin >> a >> bb>>n;
	while (bb > a * 4) bb -= a * 4;
	for (long int i = 0; i<n; i++)
	{
		k = 0;
		x += y;
		while (x > a)	x -= a;
		if (l > 2)x = a - x;
		b = bb + x;
		while (b > a)
		{
			k++;
			b -= a;
		}
		l += k;
		while (l > 4)l -= 4;
		if (l == 1)
		{
			x = b; y = 0;
		}
		if (l == 2)
		{
			x = a; y = b;
		}
		if (l == 3)
		{
			x = a - b; y = a;
		}
		if (l == 4)
		{
			x = 0; y = a - b;
		}

		printf("%.10lf %.10lf\n",x,y);
	}
	//system("pause");
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (int)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T == 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = 0.0f;
    int V = ceil(L / A) - 1;
    if (L <= 4.0f * A) {
      T = L;
    } else {
      T = L - 4.0f * A;
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = A - (T - 2.0f * A);
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = A - (T - 3.0f * A);
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (int)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = A - (T - 2.0f * A);
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = A - (T - 3.0f * A);
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T == 0) y = 0;
        break;
    }
    if (x == 17179934592.00000 || y == 17179934592.00000) {
      int asdasd = 0;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = 0.0f;
    int V = ceil(L / A) - 1;
    if (L <= 4.0f * A) {
      T = L;
    } else {
      T = L - V * A;
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = A - (T - 2.0f * A);
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = A - (T - 3.0f * A);
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A + 0.000000005) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    while (T > 4.0f * A && A > 0) {
      T -= 4.0f * A;
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = A - (T - 2.0f * A);
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = A - (T - 3.0f * A);
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T - 0.0000001 <= 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T - 0.00001 <= 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    while (T > 4.0f * A) {
      T -= 4.0f * A;
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = A - (T - 2.0f * A);
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = A - (T - 3.0f * A);
        break;
    }
    if (x < 0 || y < 0) {
      int asdasd = 0;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A + 0.1) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A + 0.0001) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (int)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        if (x == A) x = 0;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T == 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T == 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    int V = ceil(L / A + 0.000000005) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T == 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

//#ifdef DK
//  static const int MAX = 303;
//#else
//  static const int MAX = 303;
//#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  int N = 0;
  double A = 0.0f, D = 0.0f;
  scanf("%lf%lf%d", &A, &D, &N);
  REPN(i, 1, N) {
    double L = i * D;
    double T = L;
    long long V = ceil(L / A) - 1;
    if (T > 4.0f * A) {
      double K = T / (4.0f * A);
      T -= (long long)K * (4.0f * A);
    }
    int idx = V % 4;
    double x = 0.0f, y = 0.0f;
    switch (idx) {
      case 0:
        x = T;
        y = 0.0f;
        break;
      case 1:
        x = A;
        y = T - A;
        break;
      case 2:
        x = 3.0f * A - T;
        y = A;
        break;
      case 3:
        x = 0.0f;
        y = 4.0f * A - T;
        if (T - 0.0001 <= 0) y = 0;
        break;
    }
    printf("%.5lf %.5lf\n", x, y);
  }
  return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.4lf %.4lf\n", x, y);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int i,k,cnt,c,n;
    double a,d,x,y,b,len,total=0.0,ans=0.0,eps=0.00001;
    scanf("%lf %lf %d", &a, &d, &n);
    //cout<<a<<b<<n;
    len=0.0;
    for(i=1,c=0; i<=n; i++)
    {
        len+=d;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%f %f\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c,n;
    double a,d,x,y,b,len,total=0.0,ans=0.0,eps=0.00001;
    scanf("%lf %lf %d", &a, &d, &n);
    //cout<<a<<b<<n;
    len=0.0;
    for(i=1,c=0; i<=n; i++)
    {
        len+=d;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%0.4f %0.4f\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.000000001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.10lf %.10lf\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int i,k,cnt,c,n;
    double a,d,x,y,b,len,total=0.0,ans=0.0,eps=0.000000001;
    scanf("%lf %lf %d", &a, &d, &n);
    //cout<<a<<b<<n;
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%f %f\n", x, y);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c,n;
    double a,d,x,y,b,len,total=0.0,ans=0.0,eps=0.00001;
    scanf("%lf %lf %d", &a, &d, &n);
    //cout<<a<<b<<n;
    len=0.0;
    for(i=1,c=0; i<=n; i++)
    {
        len+=d;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a+eps;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%0.4f %0.4f\n", x, y);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c,n;
    double a,d,x,y,b,len,total=0.0,ans=0.0,eps=0.000000001;
    scanf("%lf %lf %d", &a, &d, &n);
    //cout<<a<<b<<n;
    len=0.0;
    for(i=1,c=0; i<=n; i++)
    {
        len+=d;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%f %f\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.5lf %.5lf\n", x, y);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

double a, d;
int n;

void write(double x){
    double sum = x;
    if (sum<a){
        printf("%f %f\n", sum, 0.0);
        return;
    }
    sum-=a;
    if (sum<a){
        printf("%f %f\n", a, sum);
        return;
    }
    sum-=a;
    if (sum<a){
        printf("%f %f\n", a-sum, a);
        return;
    }
    sum-=a;
    if (sum<=a){
        printf("%f %f\n", 0.0, a-sum);
        return;
    }
}

int main(){
    scanf("%lf%lf",&a,&d);
    while (d>=4*a) d-=4*a;
    scanf("%d",&n);
    double sum = 0;
    for (int i=1;i<=n;++i){
        sum+=d;
        while (sum>=4*a) sum-=4*a;
        write(sum);
    }
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.0001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.10lf %.10lf\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.10lf %.10lf\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
   // freopen("in.txt", "r", stdin);
    int i,k,cnt,c;
    double a,d,n,x,y,b,len,total=0.0,ans=0.0,eps=0.00000001;
    scanf("%lf %lf %lf", &a, &d, &n);
    cnt=n;
    len=0.0;
    ans=n*d+0.5;
    for(i=1,c=0; i<=cnt; i++)
    {
        len+=d;
        if(len>ans) break;
            k=len/a;
            c=k%4;
            if(len>a) b=len-k*a;
            else b=len;
            if(c==0)
            {
                y=0.0;
                x=b;
            }
            else if(c==1)
            {
                y=b;
                x=a;
            }
            else if(c==2)
            {
                y=a;
                x=a-b;
            }
            else
            {
                x=0.0;
                y=a-b;
            }
            printf("%.4lf %.4lf\n", x+eps, y+eps);
            //cout<<x<<" "<<y<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000LL);
	ll d = (ll)(D*10000LL);
	d %= a;
//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll x = 0LL, y = 0LL;
		ll d2 = ((ll)i*d) % (4LL*a);
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else
		if ( d2 >= 3LL*a && d < 4LL*a ){
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.5lf %.5lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double a, d; cin >> a >> d;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		double x, y;
		ll k = i*d/a;
		double t = i*d - k*a;
		k %= 4LL;
		switch (k ){
			case 0: x = t,     y = 0  ; break;
			case 1: x = a,     y = t  ; break;
			case 2: x = a - t, y = a  ; break;
			case 3: x = 0,     y = a-t; break;
		} // end switch

		printf ("%.5lf %.5lf\n", x, y );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	int a = (int)(A*10000);
	int d = (int)(D*10000);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		int d2 = (i*d) % (4*a);
		int x, y;
		if (d2 >= 0 && d2 < a ){
			x = d2; y = 0;
		}else
		if (d2 >= a && d2 < 2*a ){
			x = d2, y = d2-a;
		}else
		if (d2 >= 2*a && d2 < 3*a ){
			x = 3*a - d2, y = a;
		}else{	// if ( d2 >= 3*a && d < 4*a )
			x = 0, y = 4*a - d2;
		} // end if
		printf ("%.9lf %.9lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000LL);
	ll d = (ll)(D*10000LL);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll x = 0LL, y = 0LL;
		ll d2 = ((ll)i*d) % (4LL*a);
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else
		if ( d2 >= 3LL*a && d < 4LL*a ){
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.4lf %.4lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	int a = (int)(A*10000);
	int d = (int)(D*10000);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		int d2 = (i*d) % (4*a);
		int x, y;
		if (d2 >= 0 && d2 < a ){
			x = d2; y = 0;
		}else
		if (d2 >= a && d2 < 2*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2*a && d2 < 3*a ){
			x = 3*a - d2, y = a;
		}else{	// if ( d2 >= 3*a && d < 4*a )
			x = 0, y = 4*a - d2;
		} // end if
		printf ("%.9lf %.9lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000LL);
	ll d = (ll)(D*10000LL);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll x = 0LL, y = 0LL;
		ll d2 = ((ll)i*d) % (4LL*a);
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else
		if ( d2 >= 3LL*a && d < 4LL*a ){
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.10lf %.10lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double a, d; cin >> a >> d;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		double x, y;
		int k = i*d/a;
		double t = i*d - k*a;
		k %= 4;
		switch (k ){
			case 0: x = t,     y = 0  ; break;
			case 1: x = a,     y = t  ; break;
			case 2: x = a - t, y = a  ; break;
			case 3: x = 0,     y = a-t; break;
		} // end switch

		printf ("%.5lf %.5lf\n", x, y );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000LL);
	ll d = (ll)(D*10000LL);
	d %= 4LL*a;
//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll x = 0LL, y = 0LL;
		ll d2 = ((ll)i*d) % (4LL*a);
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else
		if ( d2 >= 3LL*a && d < 4LL*a ){
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.5lf %.5lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}