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 <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int dx[] ={-1,0,1,0};
int dy[] ={0,-1,0,1};

int q1, b, c1, c2, q2;

bool check(int m){
	if(m > q2) return false;
	if(m * c1 > b) return false;
	int n = b - m * c1;
	if(m + n / c2 < q1) return false;
	return true;
}

int main(){
	int l, r, m;
	int a1, a2;
	while(cin>>q1 && q1){
		cin>>b>>c1>>c2>>q2;
		l = 0; r = q2;
		rep(i, 30){
			m = (l + r) / 2;
			if(check(m+1)){
				l = m+1;
			}
			else if(check(m)){
				l = m;
			}
			else {
				r = m;
			}
		}
		if(l == 0){
			cout<<"NA"<<endl;
			continue;
		}
		cout<<l<<" "<<(b-m*c1)/c2<<endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int Q1, B, C1, C2, Q2; cin >> Q1;
		if (!Q1)break;
		cin>> B >> C1 >> C2 >> Q2;
		pair<int, int>ans=make_pair(-1,-1);
		for (int a = Q2; a >= 1; --a) {
			int rest = B - a*C1;
			if (rest < 0)continue;
			int n = rest / C2;
			if (a + n >= Q1) {

				ans = make_pair(a, n);
				break;
			}
		}
		if (ans.first == -1)cout << "NA" << endl;
		else cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	while(true){
		
		long long int b, c1, c2, q1, q2;
		
		cin >> q1;
		
		if(q1 == 0){
			break;
		}
		
		cin >> b >> c1 >> c2 >> q2;
		
		long long int ans1, ans2;
		
		if(c1 <= c2){
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}else if(q1 * c1 > b){
			ans1 = min((b - q1 * c2) / (c1 - c2), q2);
			ans2 = (b - c1 * ans1) / c2;
		}else{
			ans1 = min(b / c1, q2);
			ans2 = (b - c1 * ans1) / c2;
		}
		
		
		if(ans1 < 1 || ans2 < 0){
			cout << "NA" << endl;
		}else{
			cout << ans1 << " " << ans2 << endl;
		}
		
		//cout << ans1 << " " << ans2 << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
main(){
  int q,b,c1,c2,q2;
  while(cin>>q,q){
    cin>>b>>c2>>c1>>q2;
    int a1=0,a2=0;
    r(i,q2+1)if((b-i*c2)>=0){
      int f=(b-i*c2)/c1;
      if(i+f>=q){
        if(a1<i){
          a1=i;
          a2=f;
        }
      }
    }
    if(a1==0)cout<<"NA"<<endl;
    else cout<<a1<<' '<<a2<<endl;
  }
}

C++: //45
#include<iostream>

using namespace std;

int main(){
  for(int q,b,c,cc,qq;cin>>q>>b>>c>>cc>>qq,q;){
    int a=0;
    int n=b/cc;
    int r=b-n*cc;
    for(;;){
      int nr=r;
      int nn=n;
      while(nr<c){
	nr+=cc;
	nn--;
      }
      if(nn<0||a+1+nn<q||a+1>qq)break;
      a++;
      n=nn;
      r=nr-c;
    }
    if(a+n<q||a==0){
      cout<<"NA"<<endl;
    }else{
      cout<<a<<' '<<n<<endl;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int q1;
	while(~scanf("%d",&q1)){
		if(q1==0) break;
		int b,c1,c2,q2;
		//1:aize chiken 2:normal chiken
		scanf("%d %d %d %d",&b,&c1,&c2,&q2);
		for(int i=q2;i>=1;i--){
			int cost = i*c1;
			if(cost > b) continue;
			int ub = 1000000;
			int lb = 0;

			for(int j=0;j<20;j++){
				int md = (ub+lb)/2;
				if(cost + md*c2 <=b) lb = md;
				else ub = md;
			}

			if(lb+i >= q1 && cost + lb*c2 <=b){
				printf("%d %d\n",i,lb);
				goto next;
			}
		}
		printf("NA\n");
next:;
	}
}

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

C++: #include <iostream>

using namespace std;

void solve()
{
	int q1, b, c1, c2, q2;
	while(cin >> q1, q1)
	{
		cin >> b >> c1 >>  c2 >>  q2;
		if(b / c1 > q1 && b / c1 <= q2)
		{
			cout << b / c1 << " " << 0 << endl;
		}
		else
		{
			int chicken = (q1 * c1 - b) / (c1 - c2) + 1;
			int aizu_chicken = q1 - chicken;
			bool flag = true;
			if(aizu_chicken <= 0)
			{
				cout << "NA" << endl;
				flag = false;
			}
			if(flag)
			{
				if(aizu_chicken > q2)
				{
					aizu_chicken = q2;
					chicken = (b - c1 * q2) / c2;
				}
				cout << aizu_chicken << " " << chicken << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

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

int main() {
  
  int Q1, B, C1, C2, Q2;
  
  while(cin >> Q1) {
    
    if(Q1 == 0) break;
    
    cin >> B >> C1 >> C2 >> Q2;
    
    stringstream ss; ss << "Q: " << Q1 << " B: " << B << " C1: " << C1 << " C2: " << C2 << " Q2: " << Q2;
    
    assert(Q2 >= 1 && ss.str().c_str());
    
    /*
    if(B/C1 == 0) {
      failed(); continue;
    }
    */
    
    int AizuCh = min(B/C1, Q2);
    if(AizuCh <= 0) { failed(); continue; }
    int NCh = 0;
    for(;;) {
      
      NCh = (B - AizuCh*C1)/C2;
      
      /*
      if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        NCh = (B - 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;
}