#include using namespace std; #define MAX 51000 int n, m, sum; int x1[MAX], y1[MAX], b1[MAX]; struct tower { int x, y, b; bool operator<(const tower& r) { if(b < r.b)return true; return false; } } t[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("war.in", "r", stdin); freopen("war.out", "w", stdout); cin >> n >> m; for(int i = 0; i < n; i++) { cin >> x1[i] >> y1[i] >> b1[i]; sum += b1[i]; } for(int i = 0; i < m; i++) { cin >> t[i].x >> t[i].y >> t[i].b; } sort(t, t + m); cout << n - 1 + m << endl; for(int i = 1; i < n; i++) { cout << x1[i] << " " << y1[i] << " " << x1[0] << " " << y1[0] << " " << b1[i] << endl; } for(int i = 0; i < m; i++) { cout << x1[0] << " " << y1[0] << " " << t[i].x << " " << t[i].y << " " << sum << endl; x1[0] = t[i].x; y1[0] = t[i].y; sum = ceil(sqrt(sum * sum - t[i].b * t[i].b)); } return 0; }