#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector <ll> b(16);
    ll now = 1;
    rep(i,16){
        b[i] = now;
        now *= 10;
    }


    ll ans = 0;
    if(n == b[15]){
        ans = 5 + 4 * (b[15] - b[12]) + 3 * (b[12] - b[9]) + 2 * (b[9] - b[6]) + (b[6] - b[3]);
    }
    else if(n >= b[12]){
        ans = 4 * (n + 1 - b[12]) + 3 * (b[12] - b[9]) + 2 * (b[9] - b[6]) + (b[6] - b[3]);
    }
    else if(n >= b[9]){
        ans = 3 * (n + 1 - b[9]) + 2 * (b[9] - b[6]) + (b[6] - b[3]);
    }
    else if(n >= b[6]){
        ans = 2 * (n + 1 - b[6]) + (b[6] - b[3]);
    }
    else if(n >= b[3]){
        ans = (n + 1 - b[3]);
    }
    else ans = 0;

    cout << ans << endl;

} 

# include <bits/stdc++.h>
# ifndef ngng628_library
# define ngng628_library
# define int long long
# define float long double
# define fi first
# define se second
# define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i,n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i,n) for(int i=((int)(n)); i>0; --i)
# define repr(i,b,e) for(int i=(b), i##_len=(e); i<i##_len; ++i)
# define reprs(i,b,e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define all(x) std::begin(x), std::end(x)
# define rall(x) std::rbegin(x), std::rend(x)
# define pb push_back
# define eb emplace_back
# define len(x) ((int)(x).size())
# define lb(v,x) distance(std::begin(v), lower_bound(all(v), (x)))
# define ub(v,x) distance(std::begin(v), upper_bound(all(v), (x)))
using namespace std;
template<class T> using vec = vector<T>;
using pii = pair<int, int>;
using vi = vec<int>;
using vb = vec<bool>;
using vvb = vec<vb>;
using vvvb = vec<vvb>;
using vs = vec<string>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
constexpr int INF = (1LL<<62)-(1LL<<31);
constexpr float EPS = 1e-10;
template<class T> istream& operator>>(istream& is, vec<T>& v) { for (auto& x : v) is >> x; return is; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.fi >> p.se; }
template<class T> T scan() { T ret; cin >> ret; return ret; }
template<class T> string join(const vec<T> &v){ stringstream s; rep (i, len(v)) s<<' '<<v[i]; return s.str().substr(1); }
template<class T> ostream& operator<<(ostream& os, const vec<T>& v){ if (len(v)) os << join(v); return os; }
template<class T> ostream& operator<<(ostream& os, const vec<vec<T>>& v){ rep (i, len(v)) { if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ os << p.fi << " " << p.se; return os; }
template<class T, class U, class V> ostream& operator<<(ostream& os, const tuple<T, U, V>& t){ os << get<0>(t) << " " << get<1>(t) << " " << get<2>(t); return os; }
void print(){ cout << "\n"; }
template<class T, class... A>void print(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; print(args...);}
void eprint() { cerr << "\n"; }
template<class T, class... A>void eprint(const T& v, const A&...args){cerr << v; if(sizeof...(args))cerr << " "; eprint(args...);}
void drop(){ cout << "\n"; exit(0); }
template<class T, class... A>void drop(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; drop(args...);}
template<class T> inline constexpr bool chmax(T &a, const T& b) { return a < b && (a = b, true); }
template<class T> inline constexpr bool chmin(T &a, const T& b) { return a > b && (a = b, true); }
constexpr int ctoi(const char c) { return ('0' <= c and c <= '9') ? (c - '0') : -1; }
const char* yn(bool b) { return b ? "Yes" : "No"; }
# endif  // ngng628_library

struct Ad {
   int x, y, r;
   int id;
   Ad() = default;
   Ad(int _x, int _y, int _r, int _id) : x(_x), y(_y), r(_r), id(_id) {}
};
ostream& operator<<(ostream& os, const Ad& a){ 
   printf("%4lld | %4lld %4lld %7lld", a.id, a.x, a.y, a.r);
   return os;
}


int32_t main() {
   int n;
   cin >> n;
   vec<Ad> ads(n);
   rep (i, n) {
      cin >> ads[i].x >> ads[i].y >> ads[i].r;
      ads[i].id = i;
   }

   rep (i, n) {
      auto& ad = ads[i];
      printf("%lld %lld %lld %lld\n", ad.x, ad.y, min(ad.x + 1LL, 10000LL), min(ad.y + 1LL, 10000LL));
   }
}