Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		if buf[0] == "0" {
			break
		}
		q1, _ := strconv.Atoi(buf[0]) // 買うべき鶏肉の量の下限(g)
		b, _ := strconv.Atoi(buf[1])  // 予算
		c1, _ := strconv.Atoi(buf[2]) // 会津地鶏の値段(/100g)
		c2, _ := strconv.Atoi(buf[3]) // 普通の鶏肉の値段(/100g)
		q2, _ := strconv.Atoi(buf[4]) // 会津地鶏の買える量の上限(g)
		maxAizuChiken := min(b/c1, q2)
		if maxAizuChiken <= 0 {
			fmt.Println("NA")
			continue
		}
		if c2 >= c1 {
			maxNormalChiken := (b - maxAizuChiken*c1) / c2
			if maxAizuChiken+maxNormalChiken < q1 { // 買い切ったけども必要な鶏肉の下限に達しなかった
				fmt.Println("NA")
			} else {
				fmt.Println(maxAizuChiken, maxNormalChiken)
			}
			continue
		}
		if (b-c1)/c2+1 < q1 { // 会津地鶏を1単位+普通の鶏肉を予算目一杯買ったが買うべき下限を超えなかった
			fmt.Println("NA")
			continue
		}
		// 二分探索
		low, high := 0, maxAizuChiken+1
		for high-low > 1 {
			mid := (low + high) / 2
			if check(mid, b, c1, c2, q1) {
				low = mid
			} else {
				high = mid
			}
		}
		fmt.Println(low, (b-low*c1)/c2)
	}
}

func check(mid, b, c1, c2, q1 int) bool {
	if mid+(b-mid*c1)/c2 < q1 {
		return false
	}
	return true
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

C++: // 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const pair<int, int> NIL(-1, -1);
 
signed main() {
    int Q1, B, C1, C2, Q2;
    while(cin >> Q1, Q1) {
        cin >> B >> C1 >> C2 >> Q2;

        pair<int, int> ans = NIL;
        for(int i=Q2; i>=1; i--) {
            if(i * C1 > B) continue;
            int normal = (B - i * C1) / C2;
            if(i + normal < Q1) continue;

            ans = make_pair(i, normal);
            break;
        }

        if(ans != NIL) {
            cout << ans.first << " " << ans.second << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int a, b, c, d, e;

bool check(int m) {
  if (m * c > b) return false;
  return m + (b - m * c) / d >= a;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> a >> b >> c >> d >> e, a) {
    int ok = 0, ng = min(e, b / c) + 1;
    while (ng - ok > 1) {
      int m = (ok + ng) / 2;
      if (check(m)) ok = m;
      else ng = m;
    }
    if (ok == 0) cout << "NA" << endl;
    else cout << ok << " " << (b - ok * c) / d << endl;
  }

  return 0;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int q1,b,c1,c2,q2,a,d;
	while(cin>>q1>>b>>c1>>c2>>q2,q1)if((b-c1)/c2+1<q1)cout<<"NA"<<endl;
	else{
		int a=b/c1>q2?q2:b/c1,sum=a*c1,d=(b-a*c1)/c2;
		for(;a+d<q1;){
			a--;
			d=(b-a*c1)/c2;
		}
		cout<<a<<" "<<d<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

void failed() {
  cout << "NA" << endl;
}

int main() {
  
  int Q1, B, C1, C2, Q2;
  
  while(cin >> Q1 >> B >> C1 >> C2 >> Q2) {
    if(Q1 == 0) break;
    
    if(B/C1 == 0) {
      failed(); continue;
    }
    
    int AizuCh = min(B/C1, Q2);
    int NCh = 0;
    for(;;) {
      
      if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        NCh += (B - NCh*C2 - AizuCh*C1)/C2;
      }
      if(AizuCh + NCh >= Q1) {
        cout << AizuCh << ' ' << NCh << endl; break;
      }
      /*
      else if(B - (NCh+1)*C2 - (AizuCh-1)*C1 >= 0) {
        NCh ++, AizuCh --;
      }
      */
      else AizuCh --;
      
      if(AizuCh <= 0) { failed(); break; }
    }
    
  }
  
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
		int aizu_ckn = 0, ckn = 0;
		int q1,q2,b,c1,c2;
		cin>>q1;
		if(q1==0)
			break;
		cin>>b>>c1>>c2>>q2;

		aizu_ckn=b/c1;
		if(aizu_ckn>q2)
			aizu_ckn=q2;
		b-=aizu_ckn*c1;
		if(aizu_ckn+ckn<q1){
			ckn=q1-aizu_ckn;
			b-=ckn*c2;
			if( b<0 ){
				if(c1<=c2){
					cout<<"NA\n";
					continue;
				}
				int change=-b/(c1-c2)+1;
				aizu_ckn-=change;
				if(aizu_ckn<1){
					cout<<"NA\n";
					continue;
				}
				ckn+=change;
				b+=change*(c1-c2);
			}
		}
		if(b>0)
			ckn+=b/c2;

		if( b<0||aizu_ckn<1 )
			cout<<"NA\n";
		else
			cout<<aizu_ckn<<' '<<ckn<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b,c,d,e;
	cin >> a;
	if(a == 0)break;
	cin >> b >> c >> d >> e;
	int m1 = min(e,b / c); 
	int m = b/d;
	REP(i,m1+1){
	    int tm,tm1;
	    tm = m;
	    tm1 = m1-i;
	    while((tm) * d + (tm1) * c > b){
		tm--;
		if(tm==0) {
		    break;
		}
	    }
	    if(tm+tm1 >= a) {
		m = tm;
		m1 = tm1;
		break;
	    }else if(i == m1){
		m = 0;
		m1 = 0;
	    }
	}
	if(m1 == 0) cout << "NA" << endl;
	else cout << m1 << " " << m << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long q1,b,c1,c2,q2,d,n;
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		if(c1<=c2){
			d=min(q2,b/c1),n=(b-c1*d)/c2;
			if(d+n<q1)cout<<"NA"<<endl;
			else cout<<d<<" "<<n<<endl;
		}else{
			if(c2*(q1-1)+c1>b)cout<<"NA"<<endl;
			else{
				d=min(q2,min((b-q1*c2)/(c1-c2),b/c1)),n=(b-c1*d)/c2;
				cout<<d<<" "<<n<<endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;

int a,b,c,d,e,f;

int main(){
	while(cin>>a){
		if(a==0){break;}
		cin>>b>>c>>d>>e;
		if(a<=e){
			f=b/c;
			if(f>=a){cout<<f<<' '<<"0"<<endl;goto E;}
			else{goto F;}
		}
		if(c*e+d*(a-e)<=b){
			while(true){
				if(c*e+d*(a-e)>b){
					cout<<e<<' '<<a-e-1<<endl;
					goto E;
				}
				a++;
			}
		}
		else{
			while(true){
				if((a-e)<0 || e<0){break;}
				if(c*e+d*(a-e)<=b){
					cout<<e<<' '<<a-e<<endl;
					goto E;
				}
				e--;
			}
		}
		F:;
		cout<<"NA"<<endl;
		E:;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long q1,b,c1,c2,q2,d,n;
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		if(c2*(q1-1)+c1>b)cout<<"NA"<<endl;
		else{
			while(c1==c2);
			d=min(q2,min((b-q1*c2)/(c1-c2),b/c1)),n=(b-c1*d)/c2;
			cout<<d<<" "<<n<<endl;
		}
	}
	return 0;
}

C++: // 2011/08/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int q1;
		cin >> q1;
		if(q1==0)
			break;

		int b, c1, c2, q2;
		cin >> b >> c1 >> c2 >> q2;

		int A = 1;
		int B = (b-c1*A)/c2;
		if(b-c1*A<0||A+B<q1){
			cout << "NA" << endl;
			continue;
		}

		do{
			A++;
			B = (b-c1*A)/c2;
		}while(b-c1*A>=0&&A+B>=q1&&A<=q2);
		A--;
		B = (b-c1*A)/c2;

		cout << A << ' ' << B << endl;
	}

	return 0;
}