#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,e,f,w;
cin>>e>>a>>b>>c;
if(b>a){
swap(b,a);
}
if(c>a){
swap(c,a);
}
if(c>b){
swap(c,b);
}
f=e/b;
w=e-f*b;
cout<<b<<" "<<w;
}
/**************************************************************
Problem: 1465
User: toughuatao1
Language: C++
Result: Wrong Answer
****************************************************************/