#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

	double dist (vector <int> p1, vector <int> p2){
		return sqrt ((double)((p1[0]-p2[0])*(p1[0]-p2[0]) + (p1[1]-p2[1])*(p1[1]-p2[1]) + (p1[2]-p2[2])*(p1[2]-p2[2])));
	}
	
	double module (int* p1){
		return sqrt ((double)((p1[0])*(p1[0]) + (p1[1])*(p1[1]) + (p1[2])*(p1[2])));
	}

int main(){
	
	vector <int> p1; vector <int> v1; vector <int> p2; vector <int> v2; int R = 5;
	p1.push_back(-7163);  p1.push_back(-371);p1.push_back(-14);
	v1.push_back(-59);v1.push_back(-41);v1.push_back(-5487);
	p2.push_back(-2398);  p2.push_back(-426);p2.push_back(-5487);
	v2.push_back(-43);v2.push_back(27);v2.push_back(67);
	
	

	//if (v1[0]*v2[1] == v2[0]*v1[1] &&  v1[2]*v2[1] == v2[2]*v1[1] )  // parallel courses
			if (dist (p1,p2) <= R) return 1;
			//else  return string("NO");
			
		vector<int> np1 = p1;
		vector<int> np2 = p2;
		np1[0] += v1[0];  np1[1] += v1[1];  np1[2] += v1[2];
		np2[0] += v2[0];  np2[1] += v2[1];  np2[2] += v2[2];
		
		if (dist (p1,p2) <= dist (np1,np2)) return 0;
		
		
		// vector prod v1 x v2
		int vp[3]; 
		vp[0] = v1[1]*v2[2] - v2[1]*v1[2];
		vp[1] =  - v1[0]*v2[2] + v2[0]*v1[2];
		vp[2] = v1[0]*v2[1] - v2[0]*v1[1];
		
		double cut;
		cut = abs ((p2[0]-p1[0])*vp[0] + (p2[1]-p1[1])*vp[1] + (p2[2]-p1[2])*vp[2]);
		cut /= module (vp);
		
		cerr<<cut;
		
		if (cut <= R) return 1;
			else  return 0;
	}
