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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    ll a,b,c,d;
	    cin >> a >> b >> c >> d;
	    ll x,y,z;
	    x = a;
	    	        bool f = false;
	    while(x <= b)
	    {

	        if(x+b > c && b+c>x && x+c > b)
	        {
	            y = b;
	            z=c;
	            f= true;
	            break;
	        }
	        else
	        {
	        x++;
	        }
	    }
	    if(x+y > z && y+z>x && x+z > y)
	    {
	        if(f)
	    cout << x << " " << y << " "<< z << "\n";
	    else
	    {
	        cout << x-1 << " " << y << " "<< z << "\n";

	    }
	    }
	    else
	    {
	        x = b;
	        bool e = false;
	    while(x <= c)
	    {
	        if(x+c > d && c+d>x && x+d > c)
	        {
	            y = c;
	            z=d;
	            e = true;
	            break;
	        }
	        else
	        {
	        x++;
	        }
	    }
	    if(x+y > z && y+z >x && x+z > y)
	    {
	        if(e)
	        {
	            cout << x << " " << y << " " << z << "\n";
	        }
	        else
	        {
	            cout << x-1 << " " << y << " " << z << "\n";
	        }
	    }
	    }
	}
	return 0;
}


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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    ll a,b,c,d;
	    cin >> a >> b >> c >> d;
	    ll x,y,z;
	    x = b;
	    if(b==c)
	    {
	        y = b;
	    }
	    else
	    {
	        y = c-1;
	    }
	    if(c==d)
	    {
	        z = c;
	    }
	    else
	    {
	        z = c+1;
	    }
	    cout << x << " " << y << " "<< z << "\n";
	}
	return 0;
}


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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    ll a,b,c,d;
	    cin >> a >> b >> c >> d;
	    ll x,y,z;
	    x = a;
	    	        bool f = false;
	    while(x <= b)
	    {

	        if(x+b > c && b+c>x && x+c > b)
	        {
	            y = b;
	            z=c;
	            f= true;
	            break;
	        }
	        else
	        {
	        x++;
	        }
	    }
	    if(x+y >= z && y+z>=x && x+z >= y)
	    {
	        if(f)
	    cout << x << " " << y << " "<< z << "\n";
	    else
	    {
	        cout << x << " " << y << " "<< z << "\n";

	    }
	    }
	    else
	    {
	        x = b;
	        bool e = false;
	    while(x <= c)
	    {
	        if(x+c >= d && c+d>=x && x+d >= c)
	        {
	            y = c;
	            z=d;
	            e = true;
	            break;
	        }
	        else
	        {
	        x++;
	        }
	    }
	    if(x+y >= z && y+z >= x && x+z >= y)
	    {
	        if(e)
	        {
	            cout << x << " " << y << " " << z << "\n";
	        }
	        else
	        {
	            cout << x-1 << " " << y << " " << z << "\n";
	        }
	    }
	    }
	}
	return 0;
}


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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    ll a,b,c,d;
	    cin >> a >> b >> c >> d;
	    ll x,y,z;
	    x = b;
	    if(b==c)
	    {
	        y = b;
	    }
	    else
	    {
	        y = c;
	    }
	    if(c==d)
	    {
	        z = c;
	    }
	    else
	    {
	        z = d;
	    }
	    cout << x << " " << y << " "<< z << "\n";
	}
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	   cout<<b<<" "<<c<<" "<<c<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    cout<<a<<" "<<b<<" "<<c<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    cout<<b<<" "<<c<<" "<<c+1<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    if(c==d)cout<<b<<" "<<c<<" "<<d<<"\n";
	    if(c!=d)cout<<b<<" "<<c<<" "<<d-1<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    cout<<b<<" "<<c<<" "<<(c+d)/2<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    cout<<b<<" "<<c<<" "<<d<<"\n";
	    }
	return 0;
}


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int x,n,m;
	    cin>>x>>n>>m;
	    if(x<=10 && m>=1)cout<<"YES"<<"\n";
	    else{
	    while(n--)
	    {
	        x=floor(x/2)+10;
	    }
	    while(m--)
	    {
	        x=x-10;
	    }
	    if(x<=0)cout<<"YES"<<"\n";
	    else cout<<"NO"<<"\n";
	}
	}
	return 0;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  else if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  else if (a + c > d) {
    x = a;
    y = c;
    z = d;
  }
  else if (a + b > d) {
    x = a;
    y = b;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << x << " " << y << " " << z << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << x << " " << y << " " << z << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  if (a + c > d) {
    x = a;
    y = c;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << x << " " << y << " " << z << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  cout << a << " " << b << " "  << c << "\n";
}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  long long int a , b , c , d;
  cin >> a >> b >> c >> d;
  long long int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  else if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  else if (a + c > d) {
    x = a;
    y = c;
    z = d;
  }
  else if (a + b > d) {
    x = a;
    y = b;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << b << " " << c << " " << d << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  long long int a , b , c , d;
  cin >> a >> b >> c >> d;
  long long int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  else if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  else if (a + c > d) {
    x = a;
    y = c;
    z = d;
  }
  else if (a + b > d) {
    x = a;
    y = b;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << b << " " << c << " " << c << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/***pre processors ***/
using namespace std;
typedef long long int ll;
const long long int mod = 1e9+7;
// Functions
int ar[10000001];
ll gcd(ll a , ll b)
{
   if(b==0){
        return a;
    }
   a %= b;
   return gcd(b,a);
}
ll fexpo(ll a,ll b)
{
    if(b==0)
        return 1LL;
    if(b==1)
        return a % mod;
    if(b==2)
        return (a % mod) * (a% mod) % mod;
    if(b%2==0)
        return fexpo(fexpo(a,b/2),2);
    else
        return a % mod * (fexpo(fexpo(a,(b-1)/2),2) % mod);
}
void solve(){
  long long int a , b , c , d;
  cin >> a >> b >> c >> d;
  long long int x, y , z;
  if (a + b > c) {
    x = a;
    y = b;
    z = c;
  }

  else if (b + c > d) {
    x = b;
    y = c;
    z = d;
  }
  else if (a + c > d) {
    x = a;
    y = c;
    z = d;
  }
  else if (a + b > d) {
    x = a;
    y = b;
    z = d;
  }
  // cout << (a + b)/2  << " " << (b + c)/2 << " "  << c << "\n";
  // cout << a + b) / 2
  cout << x << " " << y << " " << z << endl;

}
int main() {
    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;
        cout<<b<<c<<d<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<b<<" "<<c<<" "<<c<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);

        }
        cout<<x<<y<<z<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);

        }
        cout<<x<<" "<<y<<" "<<z<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);
            if(y<b)
            y=b;
            if(z<c)
            z=c;

        }
        cout<<x<<" "<<y<<" "<<z<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll x,y,z;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);
            if(y<b)
            y=b;
            if(z<c)
            z=c;
            if(x+y>z||y+z>x||z+x>y){
            x=x;y=y;z=z;
            }
            else{
                y=c;z=d;
            }

        }
        cout<<x<<" "<<y<<" "<<z<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);
            if(y<b)
            y=b;
            if(z<c)
            z=c;

        }
        cout<<x<<y<<z<<endl;
    }
	return 0;
}


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

int main()
{
    ll t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll x,y,z;
        if(a==b){
            x=a;y=c;z=d;
        }
        else if(b==c){
            x=y=z=b;
        }
        else if(c==d){
            x=a;y=b;
            z=c;
        }
        else{
            x=(b-a);y=(c-a);z=(d-a);
            if(y<b)
            y=b;
            if(z<c)
            z=c;
            if(x+y<z||y+z<x||z+x<y)
            flag=1;
            else{
                y=c;z=d;
            }

        }
        cout<<x<<y<<z<<endl;
    }
	return 0;
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=(a+b)/2;
        y=(c+b)/2;
        z=(c+d)/2;

        if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        else if(x+y<z+1)
        {
            while(x<b && x+y<z+1)
            x+=1;

            while(y<c && x+y<z+1)
            y+=1;

            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
        else if(x+y>z+1)
        {
            while(z<d && x+y>z+1)
            z+=1;
            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=(a+b)/2;
        y=(c+b)/2;
        z=(c+d)/2;

        if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;

        else if(x+y<z+1)
        {
            while(x<b-10000 && x+y<z+1)
            x+=10000;
            while(x<b && x+y<z+1)
            x+=1;

            while(y<c-10000 && x+y<z+1)
            y+=10000;
            while(y<c && x+y<z+1)
            y+=1;

            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }

        else if(x+y>z+1)
        {
            while(z<d-10000 && x+y>z+1)
            z+=10000;
            while(z<d && x+y>z+1)
            z+=1;
            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=a;
        y=b;
        z=c;

        if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        else if(x+y<z+1)
        {
            while(x<b && x+y<z+1)
            x+=1;

            while(y<c && x+y<z+1)
            y+=1;

            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
        else if(x+y>z+1)
        {
            while(z<d && x+y>z+1)
            z+=1;
            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }

}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=(a+b)/2;
        y=(c+b)/2;
        z=(c+d)/2;

        if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;

        else if(x+y<z+1)
        {
            while(y<c-10000 && x+y<z+1)
            y+=10000;
            while(y<c && x+y<z+1)
            y+=1;
            if(x+y>=z+1 && z+1>y){
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
            continue;
            }

            while(x<b-10000 && x+y<z+1)
            x+=10000;
            while(x<b && x+y<z+1)
            x+=1;

            if(x+y>=z+1 && z+1>y)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }

        else if(x+y>z+1)
        {
            while(z<d-10000 && x+y>z+1)
            z+=10000;
            while(z<d && x+y>z+1)
            z+=1;
            if(x+y>=z+1 && z+1>y)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<a<<" "<<b<<" "<<c<<" "<<c<<endl;

    }
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define mn      *min_element
#define mx      *max_element
#define w(t)    int t; cin>>t; while(t--)
#define fio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fio
    w(t)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        cout<<b<<" "<<c<<" "<<c<<endl;

    }
	return 0;
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=(a+b)/2;
        y=(c+b)/2;
        z=(c+d)/2;

        if(x+y>z && z>y)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;

        else if(x+y<z)
        {
            while(y<c-10000 && x+y<z)
            y+=10000;

            while(y<c && x+y<=z)
            y+=1;

            if(x+y>z && z>y)
            {
                std::cout <<x<<" "<<y<<" "<<z<< std::endl;
                continue;
            }

            while(x<b-10000 && x+y<z)
            x+=10000;

            while(x<b && x+y<=z)
            x+=1;

            if(x+y>z && z>y)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }

        else if(x+y>z+1)
        {
            while(z<d-10000 && x+y>z)
            z+=10000;

            while(z<d && x+y>=z)
            z+=1;

            if(x+y>z && z>y)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }
}


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

#define ll      long long int
#define pb      push_back
#define vi      vector<int>
#define mod     1000000007
#define w(t)    int t; cin>>t; while(t--)

int main()
{
    w(t)
    {
        ll a,b,c,d,x,y,z;
        cin>>a>>b>>c>>d;

        x=(a+b)/2;
        y=(c+b)/2;
        z=(c+d)/2;

        if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;

        else if(x+y<z+1)
        {
            while(x<b-10 && x+y<z+1)
            x+=10;
            while(x<b && x+y<z+1)
            x+=1;

            while(y<c-10 && x+y<z+1)
            y+=10;
            while(y<c && x+y<z+1)
            y+=1;

            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }

        else if(x+y>z+1)
        {
            while(z<d-10 && x+y>z+1)
            z+=10;
            while(z<d && x+y>z+1)
            z+=1;
            if(x+y==z+1)
            std::cout <<x<<" "<<y<<" "<<z<< std::endl;
        }
    }
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        // if(d-c<b||(d==b&&d==c))
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(d-b<a||(d==b&&d==a))
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(c-b<a||(c==b&&c==a))
        // cout<<a<<" "<<b<<" "<<c<<endl;
        if(a==b&&b==c)
        cout<<a<<" "<<b<<" "<<c<<endl;
        else if(b==c&&c==d)
        cout<<b<<" "<<c<<" "<<d<<endl;
        else if(a+b>c&&a+c>b)
        cout<<a<<" "<<b<<" "<<c<<endl;
        // else if(a+b>d&&a+d>b)
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(a+c>d&&a+d>c)
        // cout<<a<<" "<<c<<" "<<d<<endl;
        else if(b+c>d&&b+d>c)
        cout<<b<<" "<<c<<" "<<d<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        if(d-c<b)
        cout<<b<<" "<<c<<" "<<d<<endl;
        else if(d-b<a)
        cout<<a<<" "<<b<<" "<<d<<endl;
        else if(c-b<a)
        cout<<a<<" "<<b<<" "<<c<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        // if(d-c<b||(d==b&&d==c))
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(d-b<a||(d==b&&d==a))
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(c-b<a||(c==b&&c==a))
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // if(a==b&&b==c)
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // else if(b==c&&c==d)
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(a+b>c&&a+c>b)
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // // else if(a+b>d&&a+d>b)
        // // cout<<a<<" "<<b<<" "<<d<<endl;
        // // else if(a+c>d&&a+d>c)
        // // cout<<a<<" "<<c<<" "<<d<<endl;
        // else if(b+c>d&&b+d>c)
        // cout<<b<<" "<<c<<" "<<d<<endl;
        cout<<b<<" "<<c<<" "<<c<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        // if(d-c<b||(d==b&&d==c))
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(d-b<a||(d==b&&d==a))
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(c-b<a||(c==b&&c==a))
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // if(a==b&&b==c)
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // else if(b==c&&c==d)
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(a+b>c&&a+c>b)
        // cout<<a<<" "<<b<<" "<<c<<endl;
        // // else if(a+b>d&&a+d>b)
        // // cout<<a<<" "<<b<<" "<<d<<endl;
        // // else if(a+c>d&&a+d>c)
        // // cout<<a<<" "<<c<<" "<<d<<endl;
        // else if(b+c>d&&b+d>c)
        // cout<<b<<" "<<c<<" "<<d<<endl;
        cout<<b<<" "<<c<<" "<<d<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        if(d-c<b||(d==b&&d==c))
        cout<<b<<" "<<c<<" "<<d<<endl;
        else if(d-b<a||(d==b&&d==a))
        cout<<a<<" "<<b<<" "<<d<<endl;
        else if(c-b<a||(c==b||c==a))
        cout<<a<<" "<<b<<" "<<c<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        // if(d-c<b||(d==b&&d==c))
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(d-b<a||(d==b&&d==a))
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(c-b<a||(c==b&&c==a))
        // cout<<a<<" "<<b<<" "<<c<<endl;

        cout<<a<<" "<<b<<" "<<c<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        if(d-c<b||(d==b&&d==c))
        cout<<b<<" "<<c<<" "<<d<<endl;
        else if(d-b<a||(d==b&&d==a))
        cout<<a<<" "<<b<<" "<<d<<endl;
        else if(c-b<a||(c==b&&c==a))
        cout<<a<<" "<<b<<" "<<c<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


#include<bits/stdc++.h>
#define PII pair<int,int>
#define pb push_back
#define ll long long
using namespace std;
using namespace std::chrono;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = high_resolution_clock::now();
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        // if(d-c<b||(d==b&&d==c))
        // cout<<b<<" "<<c<<" "<<d<<endl;
        // else if(d-b<a||(d==b&&d==a))
        // cout<<a<<" "<<b<<" "<<d<<endl;
        // else if(c-b<a||(c==b&&c==a))
        // cout<<a<<" "<<b<<" "<<c<<endl;
        if(a==b&&b==c)
        cout<<a<<" "<<b<<" "<<c<<endl;
        else if(b==c&&c==d)
        cout<<b<<" "<<c<<" "<<d<<endl;
        else if(a+b>c&&a+c>b)
        cout<<a<<" "<<b<<" "<<c<<endl;
        else if(a+b>d&&a+d>b)
        cout<<a<<" "<<b<<" "<<d<<endl;
        else if(a+c>d&&a+d>c)
        cout<<a<<" "<<c<<" "<<d<<endl;
        else if(b+c>d&&b+d>c)
        cout<<b<<" "<<c<<" "<<d<<endl;

    }

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
//	cout << "Time taken by function: "<< duration.count() << "microseconds"<< endl;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
ll t;
cin >> t;
while(t--){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << a  << " "<< b  << " " << c<< "\n";
  } return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
ll t;
cin >> t;
while(t--){
  ll a,b,c,d,x,y,z;
  cin >> a >> b >> c >> d;
   z=d;
  if((d-1)>=b && (d-1)<=c)
  y=d-1;
  else
  y=c;
  if((d-2)>=a && (d-2)<=b)
  x=d-2;
  else
  x=b;

  if(x+y<=z)
  y=z;
  cout <<x  << " "<< y  << " " << z<< "\n";
  } return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << a << b << c;
   return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
ll t;
cin >> t;
while(t--){
  ll a,b,c,d,x,y,z;
  cin >> a >> b >> c >> d;
   z=d;
  if((d-1)>=b && (d-1)<=c)
  y=d-1;
  else
  y=c;
  if((d-2)>=a && (d-2)<=b)
  x=d-2;
  else
  x=b;

  cout <<x  << " "<< y  << " " << z<< "\n";
  } return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
   ll t;
   cin >> t;
   while(t--)
   {
   	ll a,b,c,d,x,y,z;
   	cin >> a >> b >> c >> d;
   	z=d;
   	if(c==d)
   	{
   		y=d;
   		x=b;
   	}
   	else
   	{
   		if(b==c && b+c>=d)
   		{
   			x=c;
   			y=c;
   		}
   		else if(b==c && b+c<d)
   		{
   			x=c;
   			y=c;
   			z=c;
   		}
   		else
   		{
   		x=b;
   		y=c;
   		z=c;
   	    }
   	}

   cout << x  << " "<< y  << " "<< z << "\n";

   }
   return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
   ll t;
   cin >> t;
   while(t--)
   {
   	ll a,b,c,d,x,y,z;
   	cin >> a >> b >> c >> d;
   	z=d;
   	if(c==d)
   	{
   		y=d;
   		x=b;
   	}
   	else
   	{
   		if(b==c && b+c>d)
   		{
   			x=c;
   			y=c;
   		}
   		else if(b==c && b+c<d)
   		{
   			x=c;
   			y=c;
   			z=c;
   		}
   		else
   		{
   		x=b;
   		y=c;
   		z=c;
   	    }
   	}

   cout << x  << " "<< y  << " "<< z << "\n";

   }
   return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
ll t;
cin >> t;
while(t--){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << d-2  << " "<< d-1  << " " << d<< "\n";
  } return 0;
}


/****************************************
**     by VISHAL TEKWANI               **
****************************************/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define MP make_pair
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
fast;
   ll t;
   cin >> t;
   while(t--)
   {
   	ll a,b,c,d,x,y,z;
   	cin >> a >> b >> c >> d;
   	z=d;
   	if(c==d)
   	{
   		y=d;
   		x=b;
   	}
   	else
   	{
   		if(b==c && b+c>=d)
   		{
   			x=c;
   			y=c;
   		}
   		else if(b==c && b+c<d)
   		{
   			x=c;
   			y=c;
   			z=c;
   		}
   		else
   		{
   		x=b;
   		y=c;
   	    }
   	}

   cout << x  << " "<< y  << " "<< z << "\n";

   }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int limit=0;
	cin>>limit;
	while(limit--)
	{
		long long int a=0,b=0,c=0,d=0,x=0,y=0,z=0,area=0,flag=0,s=0,i=1,j=1,k=1;
		cin>>a>>b>>c>>d;
		x=a;
		y=b;
		z=c;
		while(x<=b&&flag==0&&i<=2)
		{
			while(y<=c&&flag==0&&j<=2)
			{
				while(z<=d&&flag==0&&k<=2)
				{
					if(x+y<=z)
					flag=1;
					if(x+z<=y)
					flag=1;
					if(y+z<=x)
					flag=1;

					z=d;
					k++;
				}
				y=c;
				z=c;
				j++;
				k=1;
			}
			x=b;
			y=b;
			z=c;
			i++;
			j=1;k=1;
		}
		if(flag==1)
		cout<<x<<" "<<y<<" "<<z<<"\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int limit=0;
	cin>>limit;
	while(limit--)
	{
		long long int a=0,b=0,c=0,d=0;
		cin>>a>>b>>c>>d;

		cout<<a<<" "<<b<<" "<<c<<"\n";
	}
}


//something is never samething
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<map>
#include<sstream>
#include<cmath>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;                            //int128_t,int256_t,int512_t,int1024_t
using namespace std;
#define int long long int
#define ll long long
#define pus push_back
#define ff first
#define ss second
#define vi vector<long long int>
#define kumar(); ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(n,b) for(int i=0;i<b;i+=b)
#define loop2(a,b) for(int i=a;i<b;i++)
#define loop3(a,b,k) for(int j=a,j<b;j+=k)
int chsstream(string str)
{
	stringstream gaurav;
	int num=0;
	gaurav<<str;
	gaurav>>num;

	return num;
}
string strchsstream(int num)
{
	ostringstream gaurav;
	gaurav<<num;
	string singh=gaurav.str();

	return singh;
}

bool chTri(int a,int b,int c)
{
	if(a+b<=c)
	return false;
	if(a+c<=b)
	return false;
	if(b+c<=a)
	return false;

	return true;
}
int32_t main()
{
	kumar();

	int limit=0;
	cin>>limit;
	while(limit--)
	{
	  int a=0,b=0,c=0,d=0,i=0,j=0,k=0;
	  cin>>a>>b>>c>>d;
	  int arr[]={a,b};
	  int brr[]={b,c};
	  int crr[]={c,d};

	  loop(i,2)
	  {
	  	loop(j,2)
	  	{
	  	  loop(k,2)
			{
				if(chTri(arr[i],brr[j],crr[k]))
				{
					cout<<arr[i]<<" "<<brr[j]<<" "<<crr[k]<<"\n";
					goto A;
				}
			}
		}
	  }
	  A:;
	}
}


#include <bits/stdc++.h>

using namespace std;

#define MAXNM 200001

typedef long long ll;

typedef pair<int,int> pr;
#define f first
#define s second

int n, m;
ll c[MAXNM];
vector<pr> v[MAXNM];
int color[MAXNM], visit[MAXNM], fa[MAXNM], fa_e[MAXNM], tmp[MAXNM], tmp_e[MAXNM];
bool bipart = true;
int w1, w2, no, tmp_no;

ll w[MAXNM];

void dfs(int o, int col, bool flag)
{
    visit[o] = true;
    color[o] = col;

    for (auto t : v[o]) {
        int x = t.f;
        if (!visit[x]) {
            dfs(x, col^1, flag);

            fa[x] = o;
            fa_e[x] = t.s;
            w[t.s] += c[x];
            c[o] -= c[x];
            c[x] = 0;
        } else if (color[o] == color[x] && flag) {
            bipart = false;
            w1 = x;
            w2 = o;
            no = t.s;
        }
    }
}

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

    for (int ni = 1; ni <= n; ni++)
        scanf("%lld", &c[ni]);

    for (int mi = 0; mi < m; mi++) {
        int a, b;
        scanf("%d%d", &a, &b);

        v[a].push_back(pr(b, mi) );
        v[b].push_back(pr(a, mi) );
    }

    dfs(1, 0, true);

    for (int ni = 1; ni <= n; ni++)
        tmp[ni] = fa[ni], tmp_e[ni] = fa_e[ni];
    tmp_no = no;

    if (c[1] != 0 && bipart == true) {
        puts("NO");
    } else if (c[1] == 0) {
        puts("YES");

        for (int mi = 0; mi < m; mi++)
            printf("%lld\n", w[mi]);
    } else {
        fill(visit+1, visit+n+1, false);
        dfs(w1, 0, false);
        ll t = c[w1]/2;

        int x = w1, sign = 1;
        //cout<<w1<<" "<<w2<<endl;
        while (1) {
            w[tmp_e[x] ] += sign*t;
            sign *= -1;
            x = tmp[x];
            //cout<<x<<endl;
            if (x == w2 || x == 0) break;
        }

        w[no] += t;
        puts("YES");

        for (int mi = 0; mi < m; mi++)
            printf("%lld\n", w[mi]);
    }
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n)scanf("%lld",a+i);
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]^1]])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	ll ss=0;
	fore(i,0,n)scanf("%lld",a+i),ss+=a[i];
	assert(ss%2==0);
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	assert(s[0]+s[1]==ss);
	assert(s[0]%2==s[1]%2);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]]^1])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	ll ss=0;
	fore(i,0,n)scanf("%lld",a+i),ss+=a[i];
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]]^1])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n)scanf("%lld",a+i);
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	assert(s[0]%2==s[1]%2);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]]^1])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n)scanf("%lld",a+i);
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	assert(s[0]%2==s[1]%2);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]^1]])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ex[100005],ey[100005];
vector<int> g[100005];
int n,m,c[100005];
ll a[100005],r[100005],s[2];
vector<int> g2[100005];

void dfs0(int x){
	s[c[x]]+=a[x];
	for(int i:g[x]){
		int y=ex[i]^ey[i]^x;
		if(c[y]<0){
			c[y]=1-c[x];
			g2[x].pb(i);g2[y].pb(i);
			dfs0(y);
		}
	}
}

void dfs1(int x, int f){
	for(int i:g2[x]){
		int y=ex[i]^ey[i]^x;
		if(y==f)continue;
		dfs1(y,x);
		r[i]=a[y];
		a[x]-=r[i];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	ll ss=0;
	fore(i,0,n)scanf("%lld",a+i),ss+=a[i];
	fore(i,0,m){
		scanf("%d%d",ex+i,ey+i);ex[i]--;ey[i]--;
		g[ex[i]].pb(i);g[ey[i]].pb(i);
	}
	memset(c,-1,sizeof(c));c[0]=0;dfs0(0);
	assert(s[0]+s[1]==ss);
	assert(s[0]%2==s[1]%2);
	fore(i,0,m)if(c[ex[i]]==c[ey[i]]){
		r[i]=(s[c[ex[i]]]-s[c[ex[i]]^1])/2;
		a[ex[i]]-=r[i];
		a[ey[i]]-=r[i];
		s[c[ex[i]]]-=2*r[i];
		break;
	}
	if(s[0]!=s[1]){puts("NO");return 0;}
	dfs1(0,-1);
	puts("YES");
	fore(i,0,m)printf("%lld\n",r[i]);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int N,M;
const int MN = 100010;
vector<int> G[MN];
ll a[MN];
int d[MN];
bool vis[MN];
using P = pair<int,int>;
map<P,int> p2id;
bool spt[MN];
ll ans[MN];

void dfsd(int v = 0){
	vis[v] = 1;
	for(int u:G[v]){
		if(!vis[u]){
			d[u] = d[v]+1;
			spt[p2id[P(v,u)]] = 1;
			dfsd(u);
		}
	}
}
void dfs(int v = 0,int p = -1){
	vis[v] = 1;
	for(int u:G[v]){
		if(!vis[u]){
			dfs(u,v);
			a[v] -= a[u];
		}
	}
	if(p!=-1){
		ans[p2id[P(v,p)]] = a[v];
	}else{
		assert(a[v]==0);
	}
}
void answer(){
	puts("YES");
	rep(i,M) cout<<ans[i]<<endl;
	exit(0);
}

ll sm;	//0-1
int main(){
	cin>>N>>M;
	rep(i,N) cin>>a[i];
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
		p2id[P(x,y)] = i;
		p2id[P(y,x)] = i;
	}
	dfsd();
	rep(i,N){
		if(d[i]%2==0) sm += a[i];
		else sm -= a[i];
	}
	if(sm==0){
		rep(i,N) vis[i] = 0;
		dfs();
		answer();
	}else{
		for(auto it:p2id){
			P p = it.fs;
			int i = it.sc;
			if(spt[i]) continue;
			int x = p.fs, y = p.sc;
			if((d[x]-d[y])%2!=0) continue;

			if(d[x]%2==1) sm = -sm;
//			show(x);
//			show(y);
//			show(sm/2);
			assert(sm%2==0);
			ans[i] = sm/2;
			a[x] -= sm/2;
			a[y] -= sm/2;
//			rep(i,N) show(a[i]);
			rep(i,N) vis[i] = 0;
			dfs();
			answer();
		}
	}
	puts("NO");
}


#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxN = (int)1e5 + 10;
vector < int > g[maxN];
int c[maxN];
int p[maxN];
int prv[maxN];
bool used[maxN];
int tree[maxN];
bool ok = false;
vector < int > cycle;
vector < int > order;
void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (to == prv[v]) continue;
        if (used[to] == false) {
            prv[to] = v;
            p[to] = 1 - p[v];
            dfs(to);
            if (ok) return ;
        }
        if (p[to] == p[v]) {
            ok = true;
            while (v != to) {
                cycle.push_back(v);
                v = prv[v];
            }
            cycle.push_back(to);
            return ;
        }
    }
}
void dfs1(int v) {
    if (!used[v]) order.push_back(v);
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (used[to]) continue;
        prv[to] = v;
        dfs1(to);
    }
}
int ans[maxN];
map < pair < int, int > , int > edges;
void solve1() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    dfs1(1);
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != 1) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
        }
        else {
            if (c[1] != 0) {
                cout << "NO";
                return ;
            }
        }
    }
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
void solve2() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    for (int i = 1; i < cycle.size(); i++) {
        order.push_back(cycle[i - 1]);
        prv[cycle[i]] = cycle[i - 1];
        used[cycle[i - 1]] = true;
    }
    dfs1(cycle[cycle.size() - 1]);
    for (int i = 0; i < cycle.size(); i++) {
        dfs1(cycle[i]);
    }
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != cycle[0]) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
            c[v] = 0;
        }
    }
    //for (int i = 0; i < cycle.size(); i++) cout << cycle[i] << " ";
    //for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
    //for (int i = 1; i <= n; i++) cout << c[i] << '\n';
    int q = -c[cycle[0]] / 2;
    for (int i = 0; i + 1 < cycle.size(); i++) {
        ans[edges[minmax(cycle[i], cycle[i + 1])]] += (2 * (i % 2) - 1) * q;
    }
    ans[edges[minmax(cycle[0], cycle[cycle.size() - 1])]] = -q;
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin)  ;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> c[i];
    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        edges[make_pair(min(x, y), max(x, y))] = i;
    }
    dfs(1);
    if (!ok) {
        solve1();
    }
    else solve2();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxN = (int)1e5 + 10;
vector < int > g[maxN];
long long c[maxN];
int p[maxN];
int prv[maxN];
bool used[maxN];
int tree[maxN];
bool ok = false;
vector < int > cycle;
vector < int > order;
void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (to == prv[v]) continue;
        if (used[to] == false) {
            prv[to] = v;
            p[to] = 1 - p[v];
            dfs(to);
            if (ok) return ;
        }
        if (p[to] == p[v]) {
            ok = true;
            while (v != to) {
                cycle.push_back(v);
                v = prv[v];
            }
            cycle.push_back(to);
            return ;
        }
    }
}
void dfs1(int v) {
    if (!used[v]) order.push_back(v);
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (used[to]) continue;
        prv[to] = v;
        dfs1(to);
    }
}
long long ans[maxN];
map < pair < int, int > , long long > edges;
void solve1() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    dfs1(1);
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != 1) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
        }
        else {
            if (c[1] != 0) {
                cout << "NO";
                return ;
            }
        }
    }
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
void solve2() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    for (int i = 1; i < cycle.size(); i++) {
        order.push_back(cycle[i - 1]);
        prv[cycle[i]] = cycle[i - 1];
        used[cycle[i - 1]] = true;
    }
    dfs1(cycle[cycle.size() - 1]);
    for (int i = 0; i < cycle.size(); i++) {
        dfs1(cycle[i]);
    }
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != cycle[0]) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
            c[v] = 0;
        }
    }
    //for (int i = 0; i < cycle.size(); i++) cout << cycle[i] << " ";
    //for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
    //for (int i = 1; i <= n; i++) cout << c[i] << '\n';
    int q = -c[cycle[0]] / 2;
    for (int i = 0; i + 1 < cycle.size(); i++) {
        ans[edges[minmax(cycle[i], cycle[i + 1])]] += (2 * (i % 2) - 1) * q;
    }
    ans[edges[minmax(cycle[0], cycle[cycle.size() - 1])]] = -q;
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin)  ;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> c[i];
    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        edges[make_pair(min(x, y), max(x, y))] = i;
    }
    dfs(1);
    if (!ok) {
        solve1();
    }
    else solve2();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxN = (int)1e5 + 10;
vector < int > g[maxN];
int c[maxN];
int p[maxN];
int prv[maxN];
bool used[maxN];
int tree[maxN];
bool ok = false;
vector < int > cycle;
vector < int > order;
void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (to == prv[v]) continue;
        if (used[to] == false) {
            prv[to] = v;
            p[to] = 1 - p[v];
            dfs(to);
            if (ok) return ;
        }
        if (p[to] == p[v]) {
            ok = true;
            while (v != to) {
                cycle.push_back(v);
                v = prv[v];
            }
            cycle.push_back(to);
            return ;
        }
    }
}
void dfs1(int v) {
    if (!used[v]) order.push_back(v);
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (used[to]) continue;
        prv[to] = v;
        dfs1(to);
    }
}
int ans[maxN];
map < pair < int, int > , int > edges;
void solve1() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    dfs1(1);
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != 1) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
        }
        else {
            if (c[1] != 0) {
                cout << "NO";
                return ;
            }
        }
    }
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
void solve2() {
    memset(used, 0, sizeof used);
    memset(prv, 0, sizeof prv);
    for (int i = 1; i < cycle.size(); i++) {
        order.push_back(cycle[i - 1]);
        prv[cycle[i]] = cycle[i - 1];
        used[cycle[i - 1]] = true;
    }
    dfs1(cycle[cycle.size() - 1]);
    for (int i = 0; i < cycle.size(); i++) {
        dfs1(cycle[i]);
    }
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); i++) {
        int v = order[i];
        if (v != cycle[0]) {
            int to = prv[v];
            ans[edges[minmax(v, to)]] = c[v];
            c[to] -= c[v];
            c[v] = 0;
        }
    }
    //for (int i = 0; i < cycle.size(); i++) cout << cycle[i] << " ";
    //for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
    //for (int i = 1; i <= n; i++) cout << c[i] << '\n';
    int q = -c[cycle[0]] / 2;
    for (int i = 0; i + 1 < cycle.size(); i++) {
        ans[edges[minmax(cycle[i], cycle[i + 1])]] += (2 * (i % 2) - 1) * q;
    }
    ans[edges[minmax(cycle[0], cycle[cycle.size() - 1])]] = -q;
    cout << "YES" << '\n';
    for (int i = 1; i <= m; i++) {
        cout << ans[i] << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    freopen("input.txt", "r", stdin)  ;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> c[i];
    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        edges[make_pair(min(x, y), max(x, y))] = i;
    }
    dfs(1);
    if (!ok) {
        solve1();
    }
    else solve2();
    return 0;
}


#include <stdio.h>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
const int N=100050;
vector<pair<ll,ll> > E[N];
ll odd,s,t,mark[N],par[N],disc[N],tid,w[N],ans[N],need[N],edg[N];
void DFS(ll u, ll p)
{
	par[u]=p;
	disc[u]=++tid;
	for(ll i=0;i<E[u].size();i++)
	{
		ll v=E[u][i].first;
		ll e=E[u][i].second;
		if(!disc[v])
		{
			edg[v]=e;
			mark[v]=mark[u]^1;
			DFS(v,u);
			ans[e]+=need[v];
			need[u]-=need[v];
		}
		else if(disc[v]<disc[u] && mark[v]==mark[u])
		{
			odd=e;
			s=u;
			t=v;
		}
	}
}
ll sol[N],was[N];
void DFS(ll u)
{
	was[u]=1;
	for(ll i=0;i<E[u].size();i++)
	{
		ll v=E[u][i].first;
		ll e=E[u][i].second;
		if(!was[v] && e!=odd)
		{
			DFS(v);
			sol[e]+=w[v];
			w[u]-=w[v];
		}
	}
}
int main()
{
	ll n,i,m,u,v;
	scanf("%lld %lld",&n,&m);
	for(i=1;i<=n;i++) scanf("%lld",&w[i]),need[i]=w[i];
	for(i=1;i<=m;i++) scanf("%lld %lld",&u,&v),E[u].pb(mp(v,i)),E[v].pb(mp(u,i));
	DFS(1,0);
	if(!odd && need[1]) return printf("NO\n"),0;
	if(!need[1])
	{
		printf("YES\n");
		for(i=1;i<=m;i++) printf("%lld\n",ans[i]);
		return 0;
	}
	DFS(s);
	ll add=w[s]/2,f=1;
	for(u=s;u!=t;u=par[u],f=-f)
	{
		sol[edg[u]]+=add*f;
	}
	sol[odd]+=f*add;
	printf("YES\n");
	for(i=1;i<=m;i++) printf("%lld\n",sol[i]);
	return 0;
}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;
const int mod = 1000*1000*1000 + 7;

int n, m, c[N];
vector<pair<int,int>> g[N];
ll w[N];
int color[N];
int h[N], par[N];

int was;
vector<int> path;

ll dfs(int v, int pr = -1) {
	par[v] = pr;
	ll now = 0;
	h[v] = 1;
	for (auto& item : g[v]) {
		int to = item.first;
		int id = item.second;
		now += w[id];
		if (to == pr) continue;
		if (h[to]) {
			if (color[to] == color[v] && !was) {
				was = 1;
				int now = v;
				while (now != to) {
					path.push_back(now);
					now = par[now];
				}
				path.push_back(now);
			}
		} else {
			color[to] = color[v] ^ 1;
			ll cur = dfs(to, v);
			w[id] = cur;
			now += cur;
		}
	}
	return c[v] - now;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	REP(i, n) cin >> c[i];
	map<pair<int,int>,int> ids;
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		g[x].emplace_back(y, i);
		g[y].emplace_back(x, i);
		ids[{x, y}] = i;
		ids[{y, x}] = i;
	}

	ll now = dfs(0);

	if (!now) {
		cout << "YES\n";
		REP(i, m) cout << w[i] << '\n';
		return 0;
	}

	if (path.empty()) {
		cout << "NO\n";
		return 0;
	}

	int x = path[0], y = path.back();
	int id = ids[{x, y}];

	memset(h, 0, sizeof h);
	memset(w, 0, sizeof w);
	w[id] -= now/2;

	dfs(0);

	cout << "YES\n";
	REP(i, m) cout << w[i] << '\n';

	return 0;
}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;
const int mod = 1000*1000*1000 + 7;

int n, m, c[N];
vector<pair<int,int>> g[N];
ll w[N];
int color[N];
int h[N], par[N];

int was;
vector<int> path;

ll dfs(int v, int pr = -1) {
	par[v] = pr;
	ll now = 0;
	h[v] = 1;
	for (auto& item : g[v]) {
		int to = item.first;
		int id = item.second;
		now += w[id];
		if (to == pr) continue;
		if (h[to]) {
			if (color[to] == color[v] && !was) {
				was = 1;
				int now = v;
				while (now != to) {
					path.push_back(now);
					now = par[now];
				}
				path.push_back(now);
			}
		} else {
			color[to] = color[v] ^ 1;
			ll cur = dfs(to, v);
			w[id] = cur;
			now += cur;
		}
	}
	return c[v] - now;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	REP(i, n) cin >> c[i];
	map<pair<int,int>,int> ids;
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		g[x].emplace_back(y, i);
		g[y].emplace_back(x, i);
		ids[{x, y}] = i;
		ids[{y, x}] = i;
	}

	ll now = dfs(0);

	if (!now) {
		cout << "YES\n";
		REP(i, m) cout << w[i] << '\n';
		return 0;
	}

	if (path.empty()) {
		cout << "NO\n";
		return 0;
	}

	int x = path[0], y = path.back();
	int id = ids[{x, y}];

	memset(h, 0, sizeof h);
	memset(w, 0, sizeof w);
	w[id] -= now/2;

	if (dfs(0) != 0) {
		memset(h, 0, sizeof h);
		memset(w, 0, sizeof w);
		w[id] += now/2;
		dfs(0);
	}

	cout << "YES\n";
	REP(i, m) cout << w[i] << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define M 200005
#define ll long long

int n, m, tot;
int u[M], v[M], on_tree[M], fa[M], col[M], fath[M], dep[M];
ll c[M], mk[M];

vector<int> G[M];
unordered_map< int, unordered_map<int, ll> > val;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

inline void add_edge(int u, int v)
{ G[u].push_back(v); G[v].push_back(u); }

int findf(int x)
{ return x == fa[x] ? x : fa[x] = findf(fa[x]); }

void kruskal()
{
	for (int i = 1; i <= n; i++)
		fa[i] = i;
	for (int i = 1; i <= m; i++)
	{
		if (tot == n - 1) return;
		int uf = findf(u[i]), vf = findf(v[i]);
		if (uf == vf) continue;
		on_tree[i] = 1;
		add_edge(u[i], v[i]);
		tot++; fa[uf] = vf;
	}
}

void dfs1(int u, int c_fa, int c_col)
{
	col[u] = c_col; fath[u] = c_fa; dep[u] = dep[c_fa] + 1;
	for (int v : G[u])
	{
		if (v == c_fa) continue;
		dfs1(v, u, c_col^1);
		c[u] -= val[u][v];
	}
	val[u][c_fa] = val[c_fa][u] = c[u];
}

void work(int _x, int _y)
{
	int x = _x, y = _y;
	int dis = 0, delta = 0, flag = -1;

	if (dep[x] < dep[y]) swap(x, y);
	while (dep[x] > dep[1])
		dis++, x = fath[x];
	if (dis & 1) delta = -c[1] / 2;
	else delta = c[1] / 2;

	x = _x, y = _y;
	if (dep[x] < dep[y]) swap(x, y);
	while (dep[x] > dep[y])
	{
		val[x][fath[x]] += flag * delta, val[fath[x]][x] += flag * delta;
		flag = -flag, x = fath[x];
	}
	while (dep[x] > dep[1])
	{
		val[x][fath[x]] += flag * delta, val[fath[x]][x] += flag * delta;
		val[y][fath[y]] += flag * delta, val[fath[y]][y] += flag * delta;
		flag = -flag, x = fath[x], y = fath[y];
	}
	val[_x][_y] = val[_y][_x] = delta;
}

int main()
{
	n = read(), m = read();
	for (int i = 1; i <= n; i++)
		c[i] = read();
	for (int i = 1; i <= m; i++)
		u[i] = read(), v[i] = read();

	kruskal();

	dfs1(1, 0, 1);

	if (c[1] == 0)
	{
		puts("YES");
		for (int i = 1; i <= m; i++)
			printf("%lld\n", val[u[i]][v[i]]);
		return 0;
	}

	if (c[1] & 1)
	{
		puts("NO");
		return 0;
	}

	for (int i = 1; i <= m; i++)
	{
		if (col[u[i]] != col[v[i]] || on_tree[i]) continue;
		puts("YES");
		work(u[i], v[i]);
		for (int i = 1; i <= m; i++)
			printf("%lld\n", val[u[i]][v[i]]);
		return 0;
	}

	puts("NO");

	return 0;
}


#include <iostream>
#include <cctype>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <algorithm>
#include <cmath>
#include <utility>
#include <limits>
using namespace std;

struct Edge {
  int64_t v, id;
};

int64_t n, m, root = -1; // vertices no., edges no., odd cycle root
vector<vector<Edge>> g; // graph
vector<char> u; // visited
vector<int64_t> c; // edges calculated weights

vector<int64_t> w; // vertices wanted weights
// here weight of verticle is the sum of weights of all connected edges

vector<int64_t> cycle; // for each vertex v on odd cycle stores g[v]'s position of next edge
bool is_closed = 0; // whether whole cycle is stored

// dfs that checks if graph is bipartite (colors it with 2 colors) and finds correct weights
// if graph is not bipartite it remembers one of the odd cycle's verticles as root and for each
// vertex on cycle stores position of edge to next vertex
bool bipartite(Edge e) {
  bool is_bp = 1; // is bipartite
  c[e.id] = w[e.v]; // inital value for edge with parent
  for (uint64_t i = 0; i < g[e.v].size(); ++i) {
    Edge &x = g[e.v][i];
    if (u[x.v]) {
      if (u[x.v] == u[e.v] && root < 0) { // neighbour vertexes have same color
        root = x.v;
        is_bp = 0;
        cycle.push_back(i);
      }
      continue;
    }
    u[x.v] = (u[e.v] == 1 ? 2 : 1); // set different color then parent
    bool is_ch = bipartite(x); // is child bipartite
    if (is_bp && !is_ch && !is_closed) {
      cycle.push_back(i);
      is_closed = (e.v == root);
    }
    is_bp &= is_ch;
    c[e.id] -= c[x.id];
  }
  return is_bp;
}

// similar dfs to bipartite, but this time we don't check for odd cycles - just solve tree
void solve(Edge e) {
  c[e.id] = w[e.v]; // inital value for edge with parent
  for (auto x : g[e.v]) {
    if (u[x.v]) continue;
    u[x.v] = 1;
    solve(x);
    c[e.id] -= c[x.id];
  }
}

inline void print() {
  cout << "YES\n";
  for (int64_t i = 0; i < m; i++) cout << c[i] << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> m;
  g.resize(n); u.resize(n); w.resize(n);
  c.resize(m+1, 0);
  for (int64_t i = 0; i < n; i++) cin >> w[i];
  int64_t a, b;
  for (int64_t i = 0; i < m; i++) {
    cin >> a >> b;
    g[--a].push_back({--b,i});
    g[b].push_back({a,i});
  }

  u[0] = 1; // set first vertex as visited and color it
  if (bipartite({0,m})) {
    // apart from calculated weight of edge c stores in fact the difference
    // between wanted weight of verticle and actual weight. since we started
    // dfs with non-existing m edge we should check what value we calculated
    // for it. if it's 0 then we print solution, otherwise there's no solution
    if (c[m]) cout << "NO\n";
    else print();
  }
  else { // g has an odd cycle
    fill(u.begin(), u.end(), 0); fill(c.begin(), c.end(), 0);
    u[root] = 1;
    solve({root,m});
    // correct values on cycle
    int64_t idx = root, fix = c[m]>>1;
    for (auto it = cycle.rbegin(); it != cycle.rend(); ++it) {
      c[g[idx][*it].id] += fix;
      fix = -fix;
      idx = g[idx][*it].v;
    }
    print();
  }

  return 0;
}


#include<bits/stdc++.h>
#define st first
#define nd second

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MAXN = 2e6 + 10;

int n, m;

int _x[MAXN], _y[MAXN];
ll f[MAXN];
vector<PII> E[MAXN];
int a[MAXN], dep[MAXN], vis[MAXN];
int MAKI;

int dfs(int u, int fa, int dp, int num){
	dep[u] = dp;
	ll now = a[u];
	for (auto &v : E[u])
		if (v.st != fa && !dep[v.st]){
			dfs(v.st, u, dp + 1, v.nd);
			now -= f[v.nd];
		}
	f[num] = now;
}

int DFS(int u, int fa, int num){
	vis[u] = 1;
	ll now = a[u];
	for (auto &v : E[u])
		if (v.st != fa && !vis[v.st]){
			DFS(v.st, u, v.nd);
			now -= f[v.nd];
		}
	f[num] = now;
}

int gao(int flag){
	for (int i = 0; i <= m; i++)
		f[i] = 0, vis[i] = 0;
	int fd = 0;
	for (int i = 1; i <= m; i++)
		if ((dep[_x[i]]&1) == (dep[_y[i]]&1)){
			fd = i;
			f[i] = flag * MAKI / 2;
			a[_x[i]] -= f[i];
			a[_y[i]] -= f[i];
			break;
		}
	if (fd == 0) return 0;
	DFS(1, 0, 0);
	a[_x[fd]] += f[fd];
	a[_y[fd]] += f[fd];
	return f[0] == 0;
}

void printans(){
	puts("YES");
	for (int i = 1; i <= m; i++)
		printf("%lld\n", f[i]);
	return ;
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		_x[i] = x, _y[i] = y;
		E[x].push_back(PII(y, i));
		E[y].push_back(PII(x, i));
	}
	dfs(1, 0, 1, 0);
	if (f[0] == 0){
		printans();
		return ;
	}
	MAKI = f[0];
	//cout << MAKI << endl;
	if (gao(1)){
		printans();
		return ;
	}
	if (gao(-1)){
		printans();
		return ;
	}
	puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define st first
#define nd second

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MAXN = 2e6 + 10;

int n, m;

int _x[MAXN], _y[MAXN];
ll f[MAXN];
vector<PII> E[MAXN];
int a[MAXN], dep[MAXN], vis[MAXN];
int MAKI;

int dfs(int u, int fa, int dp, int num){
	dep[u] = dp;
	ll now = a[u];
	for (auto &v : E[u])
		if (v.st != fa && !dep[v.st]){
			dfs(v.st, u, dp + 1, v.nd);
			now -= f[v.nd];
		}
	f[num] = now;
}

int DFS(int u, int fa, int num){
	vis[u] = 1;
	ll now = a[u];
	for (auto &v : E[u])
		if (v.st != fa && !vis[v.st]){
			DFS(v.st, u, v.nd);
			now -= f[v.nd];
		}
	f[num] = now;
}

int gao(int flag){
	for (int i = 0; i <= m; i++)
		f[i] = 0, vis[i] = 0;
	int fd = 0;
	for (int i = 1; i <= m; i++)
		if ((dep[_x[i]]&1) == (dep[_y[i]]&1)){
			fd = i;
			f[i] = flag * MAKI / 2;
			a[_x[i]] -= f[i];
			a[_y[i]] -= f[i];
			break;
		}
	if (fd == 0) return 0;
	DFS(1, 0, 0);
	a[_x[fd]] += f[fd];
	a[_y[fd]] += f[fd];
	return f[0] == 0;
}

void printans(){
	puts("YES");
	for (int i = 1; i <= m; i++)
		printf("%lld\n", f[i]);
	return ;
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		_x[i] = x, _y[i] = y;
		E[x].push_back(PII(y, i));
		E[y].push_back(PII(x, i));
	}
	dfs(1, 0, 1, 0);
	if (f[0] == 0){
		printans();
		return 0;
	}
	MAKI = f[0];
	//cout << MAKI << endl;
	if (gao(1)){
		printans();
		return 0;
	}
	if (gao(-1)){
		printans();
		return 0;
	}
	puts("NO");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,col[100005];
ll sum[2],num[100005];
bool ex[2];
vector<int>edge[100005];
void dfs(int v,int c){
	if(col[v] != -1) return ;
	col[v] = c;
	sum[c] += num[v];
	rep(i,edge[v].size()){
		if(col[edge[v][i]] == -1) dfs(edge[v][i],1-c);
		else if(col[edge[v][i]] == c){
			ex[c] = 1;
		}
	}
}
P zip[100050];
map<P,ll>val;
int par[100005],ran[100005];
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
vector<int>G[100005];
ll DFS(int v,int u){
	ll V = num[v];
	rep(i,G[v].size()){
		if(G[v][i] == u) continue;
		V -= DFS(G[v][i],v);
	}
	if(u == -1) assert(V == 0LL);
	else{
		val[mp(v,u)] = val[mp(u,v)] = V;
	}
	return V;
}
int main(){
	cin>>n>>m;
	repn(i,n) cin>>num[i];
	init();
	rep(i,m){
		int a,b; cin>>a>>b;
		zip[i] = mp(a,b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	memset(col,-1,sizeof(col));
	dfs(1,0);
	if(sum[0] != sum[1] && !ex[0] && !ex[1]){
		puts("NO"); return 0;
	}
	puts("YES");
	repn(i,n){
		rep(j,edge[i].size()){
			if(i > edge[i][j]) continue;
			if(col[i] != col[edge[i][j]]){
        		continue;
			}
			ll hoge = sum[col[i]] - sum[1-col[i]];
			hoge /= 2;
			val[mp(i,edge[i][j])] = val[mp(edge[i][j],i)] = hoge;
			num[i] -= hoge;
			num[edge[i][j]] -= hoge;
			goto nxt;
		}
	}
	nxt:;
	repn(i,n){
		rep(j,edge[i].size()){
			if(i > edge[i][j]) continue;
			if(col[i] != col[edge[i][j]]){
			    int a = i, b = edge[i][j];
			    if(!same(a,b)){
        			G[a].pb(b);
        			G[b].pb(a);
        			unite(a,b);
        		}
        		continue;
			}
		}
	}
	DFS(1,-1);
	for(int i=0;i<m;i++) printf("%lld\n",val[zip[i]]);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,col[100005];
ll sum[2],num[100005];
bool ex[2];
vector<int>edge[100005];
void dfs(int v,int c){
	if(col[v] != -1) return ;
	col[v] = c;
	sum[c] += num[v];
	rep(i,edge[v].size()){
		if(col[edge[v][i]] == -1) dfs(edge[v][i],1-c);
		else if(col[edge[v][i]] == c){
			ex[c] = 1;
		}
	}
}
P zip[100050];
map<P,int>val;
int par[100005],ran[100005];
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
vector<int>G[100005];
ll DFS(int v,int u){
	ll V = num[v];
	rep(i,G[v].size()){
		if(G[v][i] == u) continue;
		V -= DFS(G[v][i],v);
	}
	if(u == -1) assert(V == 0LL);
	else{
		val[mp(v,u)] = val[mp(u,v)] = V;
	}
	return V;
}
int main(){
	cin>>n>>m;
	repn(i,n) cin>>num[i];
	init();
	rep(i,m){
		int a,b; cin>>a>>b;
		zip[i] = mp(a,b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	memset(col,-1,sizeof(col));
	dfs(1,0);
	if(sum[0] != sum[1] && !ex[0] && !ex[1]){
		puts("NO"); return 0;
	}
	puts("YES");
	repn(i,n){
		rep(j,edge[i].size()){
			if(i > edge[i][j]) continue;
			if(col[i] != col[edge[i][j]]){
        		continue;
			}
			ll hoge = sum[col[i]] - sum[1-col[i]];
			hoge /= 2;
			val[mp(i,edge[i][j])] = val[mp(edge[i][j],i)] = hoge;
			num[i] -= hoge;
			num[edge[i][j]] -= hoge;
			goto nxt;
		}
	}
	nxt:;
	repn(i,n){
		rep(j,edge[i].size()){
			if(i > edge[i][j]) continue;
			if(col[i] != col[edge[i][j]]){
			    int a = i, b = edge[i][j];
			    if(!same(a,b)){
        			G[a].pb(b);
        			G[b].pb(a);
        			unite(a,b);
        		}
        		continue;
			}
		}
	}
	DFS(1,-1);
	for(int i=0;i<m;i++) printf("%d\n",val[zip[i]]);
}


#include<bits/stdc++.h>
#define N 100010
#define RG register
using namespace std;
bool co[N],vi[N];
vector<pair<int,int> > to[N];
int a,b,m,n,cr,ed,fg,st,tp,idn,d[N],v[N],w[N],fa[N],fi[N],va[N];
inline int gi(){
    RG int x=0;RG char y=getchar();RG bool z=0;
    while((y<'0'||y>'9')&&y!='-') y=getchar();
    if(y=='-') y=getchar(),z=1;
    while(y>='0'&&y<='9') x=x*10+y-'0',y=getchar();
    return z?-x:x;
}
inline void dfs1(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
        if(!vi[t]){
	    fa[t]=x;fi[t]=id;
	    d[t]=d[x]+1;co[t]=co[x]^1;
	    dfs1(t);
	    v[x]-=v[t];w[id]+=v[t];
	}
	else if(co[t]==co[x]&&d[x]>d[t])
	    st=x,ed=t,idn=id;
    }
}
inline void dfs2(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
	if(!vi[t]&&id!=idn){
	    dfs2(t);
	    va[x]-=va[t];w[id]+=va[t];
	}
    }
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("901D.in","r",stdin);
    freopen("901D.out","w",stdout);
#endif
    n=gi();m=gi();
    for (RG int i=1;i<=n;++i)
	v[i]=va[i]=gi();
    for (RG int i=1;i<=m;++i){
	a=gi();b=gi();
	to[a].push_back(make_pair(b,i));
	to[b].push_back(make_pair(a,i));
    }
    dfs1(1);
    if(!v[1]||idn){
	if(v[1]){
	    memset(w,0,sizeof(w));
	    memset(vi,0,sizeof(vi));
	    dfs2(st);
	    cr=st;tp=va[st]>>1;fg=1;
	    while(cr!=ed){
		w[fi[cr]]+=tp*fg;
		fg*=-1;cr=fa[cr];
	    }
	    w[idn]+=tp*fg;
	}
	puts("YES");
	for (RG int i=1;i<=m;++i)
	    printf("%d\n",w[i]);
    }
    else puts("NO");
    return 0;
}


#include<bits/stdc++.h>
#define N 100010
#define RG register
using namespace std;
bool co[N],vi[N];
vector<pair<int,int> > to[N];
int a,b,m,n,cr,ed,fg,st,tp,idn,d[N],v[N],w[N],fa[N],fi[N],va[N];
inline int gi(){
    RG int x=0;RG char y=getchar();RG bool z=0;
    while((y<'0'||y>'9')&&y!='-') y=getchar();
    if(y=='-') y=getchar(),z=1;
    while(y>='0'&&y<='9') x=x*10+y-'0',y=getchar();
    return z?-x:x;
}
inline void dfs1(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
        if(!vi[t]){
	    fa[t]=x;fi[t]=id;
	    d[t]=d[x]+1;co[t]=co[x]^1;
	    dfs1(t);
	    v[x]-=v[t];w[id]=v[t];
	}
	else if(co[t]==co[x]&&d[x]>d[t])
	    st=x,ed=t,idn=id;
    }
}
inline void dfs2(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
	if(!vi[t]&&id!=idn){
	    dfs2(t);
	    va[x]-=va[t];w[id]=va[t];
	}
    }
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("901D.in","r",stdin);
    freopen("901D.out","w",stdout);
#endif
    n=gi();m=gi();
    for (RG int i=1;i<=n;++i)
	v[i]=va[i]=gi();
    for (RG int i=1;i<=m;++i){
	a=gi();b=gi();
	to[a].push_back(make_pair(b,i));
	to[b].push_back(make_pair(a,i));
    }
    dfs1(1);
    if(!v[1]||idn){
	if(v[1]){
	    memset(w,0,sizeof(w));
	    memset(vi,0,sizeof(vi));
	    dfs2(st);
	    cr=st;tp=va[st]>>1;fg=1;
	    while(cr!=ed){
		w[fi[cr]]+=tp*fg;
		fg*=-1;cr=fa[cr];
	    }
	    w[idn]=tp*fg;
	}
	puts("YES");
	for (RG int i=1;i<=m;++i)
	    printf("%d\n",w[i]);
    }
    else puts("NO");
    return 0;
}


#include<bits/stdc++.h>
#define N 100010
#define RG register
using namespace std;
typedef long long LL;
bool co[N],vi[N];
LL tp,v[N],w[N],va[N];
vector<pair<int,int> > to[N];
int a,b,m,n,cr,ed,fg,st,idn,d[N],fa[N],fi[N];
inline int gi(){
    RG int x=0;RG char y=getchar();RG bool z=0;
    while((y<'0'||y>'9')&&y!='-') y=getchar();
    if(y=='-') y=getchar(),z=1;
    while(y>='0'&&y<='9') x=x*10+y-'0',y=getchar();
    return z?-x:x;
}
inline void dfs1(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
        if(!vi[t]){
	    fa[t]=x;fi[t]=id;
	    d[t]=d[x]+1;co[t]=co[x]^1;
	    dfs1(t);
	    v[x]-=v[t];w[id]=v[t];
	}
	else if(co[t]==co[x]&&d[x]>d[t])
	    st=x,ed=t,idn=id;
    }
}
inline void dfs2(RG int x){
    vi[x]=1;
    for (RG int i=0,t,id;i<(int)to[x].size();++i){
	t=to[x][i].first,id=to[x][i].second;
	if(!vi[t]&&id!=idn){
	    dfs2(t);
	    va[x]-=va[t];w[id]=va[t];
	}
    }
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("901D.in","r",stdin);
    freopen("901D.out","w",stdout);
#endif
    n=gi();m=gi();
    for (RG int i=1;i<=n;++i)
	v[i]=va[i]=gi();
    for (RG int i=1;i<=m;++i){
	a=gi();b=gi();
	to[a].push_back(make_pair(b,i));
	to[b].push_back(make_pair(a,i));
    }
    dfs1(1);
    if(!v[1]||idn){
	if(v[1]){
	    memset(w,0,sizeof(w));
	    memset(vi,0,sizeof(vi));
	    dfs2(st);
	    cr=st;tp=va[st]>>1;fg=1;
	    while(cr!=ed){
		w[fi[cr]]+=tp*fg;
		fg*=-1;cr=fa[cr];
	    }
	    w[idn]=tp*fg;
	}
	puts("YES");
	for (RG int i=1;i<=m;++i)
	    printf("%lld\n",w[i]);
    }
    else puts("NO");
    return 0;
}


/*AMETHYSTS*/
#pragma comment(linker, "/STACK:1000000000")
#include <cstdio>
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <deque>
#include <stack>
#include <climits>
#include <string>
#include <queue>
#include <memory.h>

#define ll long long
#define ld double
#define pii pair <int, int>
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define mp make_pair
#define ull unsigned ll
#define pll pair <ll, ll>

using namespace std;

const int maxn = (int)2e5 + 10;

int ver = -1;
int num = -1;
ll c[maxn];
vector <pii> ed[maxn];
ll res[maxn];
int h[maxn];

void dfs(int v, int d) {
	h[v] = d;

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;

		if (h[u] == -1) {
			dfs(u, d + 1);
		}
	}
}

bool used[maxn];

ll go(int v) {
	used[v] = true;
	ll ans = c[v];

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;
		int w = ed[v][i].second;

		if (w == num) {
			continue;
		}

		if (!used[u]) {
			ll now = go(u);
			res[w] = now;

			ans -= now;
		}
	}

	return ans;
}

pii edg[maxn];

int main() {
	memset(h, -1, sizeof h);
	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}

	for (int i = 0; i < m; i++) {
		int a, b;

		scanf("%d %d", &a, &b);
		edg[i] = mp(a, b);

		ed[a].push_back(mp(b, i));
		ed[b].push_back(mp(a, i));
	}

	dfs(1, 0);

	for (int i = 0; i < m; i++) {
		int a = edg[i].first;
		int b = edg[i].second;

		int dst = abs(h[a] - h[b]);

		if (dst % 2 == 0) {
			ver = a;
			num = i;
			break;
		}
	}

	if (ver == -1) {
		ver = 1;
	}

	ll ch = go(ver);

	if (ch == 0) {
		cout << "YES" << endl;

		for (int i = 0; i < m; i++) {
			printf("%lld\n", res[i]);
		}

		return 0;
	}

	if (num == -1 || ch % 2 != 0) {
		cout << "NO" << endl;
		return 0;
	}

	res[num] = ch / 2;

	c[edg[num].first] -= ch / 2;
	c[edg[num].second] -= ch / 2;

	memset(used, 0, sizeof used);
	ch = go(ver);

	if (ch != 0) {
		throw 1;
	}

	cout << "YES" << endl;

	for (int i = 0; i < m; i++) {
		printf("%lld\n", res[i]);
	}

	return 0;
}


/*AMETHYSTS*/
#pragma comment(linker, "/STACK:1000000000")
#include <cstdio>
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <deque>
#include <stack>
#include <climits>
#include <string>
#include <queue>
#include <memory.h>

#define ll long long
#define ld double
#define pii pair <int, int>
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define mp make_pair
#define ull unsigned ll
#define pll pair <ll, ll>

using namespace std;

const int maxn = (int)2e5 + 10;

int ver = -1;
int num = -1;
ll c[maxn];
vector <pii> ed[maxn];
ll res[maxn];
int cl[maxn];

bool dfs(int v, int now) {
	cl[v] = now;

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;

		if (cl[u] == cl[v]) {
			ver = v;
			num = ed[v][i].second;
			return true;
		}

		if (cl[u] == -1) {
			if (dfs(u, now ^ 1)) {
				return true;
			}
		}
	}

	return false;
}

bool used[maxn];

ll go(int v) {
	used[v] = true;
	ll ans = c[v];

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;
		int w = ed[v][i].second;

		if (w == num) {
			continue;
		}

		if (!used[u]) {
			ll now = go(u);
			res[w] = now;

			ans -= now;
		}
	}

	return ans;
}

pii edg[maxn];

int main() {
	memset(cl, -1, sizeof cl);
	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}

	for (int i = 0; i < m; i++) {
		int a, b;

		scanf("%d %d", &a, &b);
		edg[i] = mp(a, b);

		ed[a].push_back(mp(b, i));
		ed[b].push_back(mp(a, i));
	}

	dfs(1, 0);

	if (ver == -1) {
		ver = 1;
	}

	ll ch = go(ver);

	if (ch == 0) {
		cout << "YES" << endl;

		for (int i = 0; i < m; i++) {
			printf("%lld\n", res[i]);
		}

		return 0;
	}

	if (num == -1 || ch % 2 != 0) {
		cout << "NO" << endl;
		return 0;
	}

	res[num] = ch / 2;

	c[edg[num].first] -= ch / 2;
	c[edg[num].second] -= ch / 2;

	memset(used, 0, sizeof used);
	ch = go(ver);

	if (ch != 0) {
		//throw 1;
	}

	cout << "YES" << endl;

	for (int i = 0; i < m; i++) {
		printf("%lld\n", res[i]);
	}

	return 0;
}


/*AMETHYSTS*/
#pragma comment(linker, "/STACK:1000000000")
#include <cstdio>
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <deque>
#include <stack>
#include <climits>
#include <string>
#include <queue>
#include <memory.h>

#define ll long long
#define ld double
#define pii pair <int, int>
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define mp make_pair
#define ull unsigned ll
#define pll pair <ll, ll>

using namespace std;

const int maxn = (int)1e5 + 10;

int ver = -1;
int num = -1;
ll c[maxn];
vector <pii> ed[maxn];
ll res[maxn];
int cl[maxn];

bool dfs(int v, int now) {
	cl[v] = now;

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;

		if (cl[u] == cl[v]) {
			ver = v;
			num = ed[v][i].second;
			return true;
		}

		if (cl[u] == -1) {
			if (dfs(u, now ^ 1)) {
				return true;
			}
		}
	}

	return false;
}

bool used[maxn];

ll go(int v) {
	used[v] = true;
	ll ans = c[v];

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;
		int w = ed[v][i].second;

		if (w == num) {
			continue;
		}

		if (!used[u]) {
			ll now = go(u);
			res[w] = now;

			ans -= now;
		}
	}

	return ans;
}

pii edg[maxn];

int main() {
	memset(cl, -1, sizeof cl);
	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}

	for (int i = 0; i < m; i++) {
		int a, b;

		scanf("%d %d", &a, &b);
		edg[i] = mp(a, b);

		ed[a].push_back(mp(b, i));
		ed[b].push_back(mp(a, i));
	}

	dfs(1, 0);

	if (ver == -1) {
		ver = 1;
	}

	ll ch = go(ver);

	if (ch == 0) {
		cout << "YES" << endl;

		for (int i = 0; i < m; i++) {
			printf("%lld\n", res[i]);
		}

		return 0;
	}

	if (num == -1 || ch % 2 != 0) {
		cout << "NO" << endl;
		return 0;
	}

	res[num] = ch / 2;

	c[edg[num].first] -= ch / 2;
	c[edg[num].second] -= ch / 2;

	memset(used, 0, sizeof used);
	ch = go(ver);

	if (ch != 0) {
		throw 1;
	}

	cout << "YES" << endl;

	for (int i = 0; i < m; i++) {
		printf("%lld\n", res[i]);
	}

	return 0;
}


/*AMETHYSTS*/
#pragma comment(linker, "/STACK:1000000000")
#include <cstdio>
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <deque>
#include <stack>
#include <climits>
#include <string>
#include <queue>
#include <memory.h>

#define ll long long
#define ld double
#define pii pair <int, int>
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define mp make_pair
#define ull unsigned ll
#define pll pair <ll, ll>

using namespace std;

const int maxn = (int)1e5 + 10;

int ver = -1;
int num = -1;
ll c[maxn];
vector <pii> ed[maxn];
ll res[maxn];
int h[maxn];
vector <pii> e[maxn];

void dfs(int v, int d) {
	h[v] = d;

	for (int i = 0; i < (int)ed[v].size(); i++) {
		int u = ed[v][i].first;

		if (h[u] == -1) {
			e[v].push_back(mp(u, ed[v][i].second));
			e[u].push_back(mp(v, ed[v][i].second));
			dfs(u, d + 1);
		}
	}
}

bool used[maxn];

ll go(int v) {
	used[v] = true;
	ll ans = c[v];

	for (int i = 0; i < (int)e[v].size(); i++) {
		int u = e[v][i].first;
		int w = e[v][i].second;

		if (w == num) {
			continue;
		}

		if (!used[u]) {
			ll now = go(u);
			res[w] = now;

			ans -= now;
		}
	}

	return ans;
}

pii edg[maxn];

int main() {
	memset(h, -1, sizeof h);
	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}

	for (int i = 0; i < m; i++) {
		int a, b;

		scanf("%d %d", &a, &b);
		edg[i] = mp(a, b);

		ed[a].push_back(mp(b, i));
		ed[b].push_back(mp(a, i));
	}

	dfs(1, 0);

	for (int i = 0; i < m; i++) {
		int a = edg[i].first;
		int b = edg[i].second;

		int dst = abs(h[a] - h[b]);

		if (dst % 2 == 0) {
			ver = a;
			num = i;
			break;
		}
	}

	if (ver == -1) {
		ver = 1;
	}

	ll ch = go(ver);

	if (ch == 0) {
		cout << "YES" << endl;

		for (int i = 0; i < m; i++) {
			printf("%lld\n", res[i]);
		}

		return 0;
	}

	if (num == -1 || ch % 2 != 0) {
		cout << "NO" << endl;
		return 0;
	}

	res[num] = ch / 2;

	c[edg[num].first] -= ch / 2;
	c[edg[num].second] -= ch / 2;

	memset(used, 0, sizeof used);
	ch = go(ver);

	if (ch != 0) {
		throw 1;
	}

	cout << "YES" << endl;

	for (int i = 0; i < m; i++) {
		printf("%lld\n", res[i]);
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 100005
vii g[MX],G[MX];
int N,M,a,b,C[MX],D[MX],X[MX],O[MX],E[MX],t[MX],R=-1,w,v,l,K[MX],H;
void go(int u){if(~E[u])K[l++]=E[u],go(t[u]);}
void clr(int u,int c){
    X[u]=c;
    for(auto&h:g[u])
        if(!X[h.aa])E[u]=h.bb,t[u]=h.aa,G[u].PB(h),G[h.aa].PB({u,h.bb}),clr(h.aa,-c);
        else if(X[h.aa]==c){
            E[u]=-1;
            if(!~R)R=t[h.aa],go(h.aa),K[l++]=h.bb;
            //TODO ELSE WHAT?
        }
}
int dfs(int u,int p,int I){
    for(auto&h:G[u])if(h.aa^p)C[u]-=dfs(h.aa,u,h.bb);
    return O[I]=C[u],C[u];
}
int main(void){
    scanf("%d%d",&N,&M),ga(N,C),memcpy(D,C,sizeof(D));
    F(M)scanf("%d%d",&a,&b),g[--a].PB({--b,i}),g[b].PB({a,i});
    clr(0,1),H=C[max(R,0)],a=dfs(max(R,0),-1,MX-1);
    H=-a;
    if(~R){
        O[*K]-=H/2,O[K[1]]-=H/2;
        FT(2,l)O[K[k]]+=k&1?-H/2:H/2;
    }
    F(N){
        for(auto&h:g[i])D[i]-=O[h.bb];
        if(D[i])return puts("NO");
    }
    puts("YES");
    F(M)printf("%d\n",O[i]);
    return 0;
}//Not correct ..but on some way.. :D [overflow and so on :P]


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%lld",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%lld",A+i);}
#define MX 100005
vii g[MX],G[MX];
int N,M,a,b,C[MX],D[MX],X[MX],O[MX],E[MX],t[MX],R=-1,w,v,l,K[MX],H;
void go(int u){if(~E[u])K[l++]=E[u],go(t[u]);}
void clr(int u,int c){
    X[u]=c;
    for(auto&h:g[u])
        if(!X[h.aa])E[u]=h.bb,t[u]=h.aa,G[u].PB(h),G[h.aa].PB({u,h.bb}),clr(h.aa,-c);
        else if(X[h.aa]==c){
            E[u]=-1;
            if(!~R)R=t[h.aa],go(h.aa),K[l++]=h.bb;
            //TODO ELSE WHAT?
        }
}
int dfs(int u,int p,int I){
    for(auto&h:G[u])if(h.aa^p)C[u]-=dfs(h.aa,u,h.bb);
    return O[I]=C[u],C[u];
}
main(void){
    scanf("%lld%lld",&N,&M),ga(N,C),memcpy(D,C,sizeof(D));
    F(M)scanf("%lld%lld",&a,&b),g[--a].PB({--b,i}),g[b].PB({a,i});
    clr(0,1),H=C[max(R,0ll)],a=dfs(max(R,0ll),-1,MX-1);
    H=-a;
    if(~R){
        O[*K]-=H/2,O[K[1]]-=H/2;
        FT(2,l)O[K[k]]+=k&1?-H/2:H/2;
    }
    F(N){
        for(auto&h:g[i])D[i]-=O[h.bb];
        if(D[i])return puts("NO");
    }
    puts("YES");
    F(M)printf("%lld\n",O[i]);
    return 0;
}//Not correct ..but on some way.. :D