Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

type Color struct {
	name    string
	R, G, B int64
}

func main() {
	colors := []Color{
		{"black", 0, 0, 0},
		{"blue", 0, 0, 0xff},
		{"lime", 0, 0xff, 0},
		{"aqua", 0, 0xff, 0xff},
		{"red", 0xff, 0, 0},
		{"fuchsia", 0xff, 0, 0xff},
		{"yellow", 0xff, 0xff, 0},
		{"white", 0xff, 0xff, 0xff},
	}
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), "")
		if buf[0] == "0" {
			break
		}
		r, _ := strconv.ParseInt(strings.Join(buf[1:3], ""), 16, 64)
		g, _ := strconv.ParseInt(strings.Join(buf[3:5], ""), 16, 64)
		b, _ := strconv.ParseInt(strings.Join(buf[5:], ""), 16, 64)
		vmin := int64(3*0xff*0xff)
		var ans string
		for _, c := range colors {
			d := (r-c.R)*(r-c.R) + (g-c.G)*(g-c.G) + (b-c.B)*(b-c.B)
			if d < vmin {
				vmin = d
				ans = c.name
			}
		}
		fmt.Println(ans)
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

tuple<int, int, int> toCol(string s) {
  int x;
  stringstream ss;
  ss << hex << s;
  ss >> x;
  return mt(x / 65536, x / 256 % 256, x % 256);
}

void solve() {
  vector<pair<string, string>> t = {
    {"black", "000000"},
    {"blue", "0000ff"},
    {"lime", "00ff00"},
    {"aqua", "00ffff"},
    {"red", "ff0000"},
    {"fuchsia", "ff00ff"},
    {"yellow", "ffff00"},
    {"white", "ffffff"},
  };
  char gomi;
  string s;
  while (cin >> gomi >> s) {
    int r, g, b;
    tie(r, g, b) = toCol(s);
    vector<pair<int, string>> v;
    for (auto &p : t) {
      int _r, _g, _b;
      tie(_r, _g, _b) = toCol(p.se);
      int d = (r - _r) * (r - _r) + (g - _g) * (g - _g) + (b - _b) * (b - _b);
      v.emplace_back(d, p.fi);
    }
    cout << (*min_element(all(v))).se << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

static const int r[ 8 ] = { 0, 0, 0, 0, 255, 255, 255, 255 }, g[ 8 ] = { 0, 0, 255, 255, 0, 0, 255, 255 }, b[ 8 ] = { 0, 255, 0, 255, 0, 255, 0, 255 };
char s;
int input_r, input_g, input_b;
int now_a;
string ans;
string a[ 8 ] = { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

int main() {
	while ( ~scanf( "%1s", &s ) && s != '0' ) {
		scanf( "%2x%2x%2x", &input_r, &input_g, &input_b );
		now_a = INF;
		for ( int i = 0; i < 8; i++ ) {
			if ( now_a > sq( r[ i ] - input_r ) + sq( g[ i ] - input_g ) + sq( b[ i ] - input_b ) ) {
				now_a = sq( r[ i ] - input_r ) + sq( g[ i ] - input_g ) + sq( b[ i ] - input_b );
				ans = a[ i ];
			}
		}
		printf( "%s\n", ans.c_str() );
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  char c;
  while(~scanf(" %c ",&c)){
    if(c=='0')break;

    int r,g,b;
    scanf("%2x%2x%2x",&r,&g,&b);
    int R[8],G[8],B[8];
    rep(i,8){
      R[i]=i/4*0xff;
      G[i]=i/2%2*0xff;
      B[i]=i%2*0xff;
    }
    string str[]={"black","blue","lime","aqua","red","fuchsia",
      "yellow","white"};

    double mind=sqrt(256*256*3)+1;
    int mini;
    rep(i,8){
      double td=sqrt((r-R[i])*(r-R[i])+(g-G[i])*(g-G[i])+(b-B[i])*(b-B[i]));
      if(td<mind){
        mind=td;
        mini=i;
      }
    }
    cout<<str[mini]<<endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

string in;
const string name[8] = {
  "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"
};

bool is_digit(char c) { return '0' <= c && c <= '9'; }
int c2i(char c) { return c - '0'; }

string solve() {
  in.erase(0, 1);
  int my[3];
  rep (i,3) my[i] = 0;
  rep (i,3) {
    if (is_digit(in[i*2])) {
      my[i] = c2i(in[i*2]) * 16;
    } else {
      my[i] = (10 + (in[i*2] - 'a')) * 16;
    }
    
    if (is_digit(in[i*2+1])) {
      my[i] += c2i(in[i*2+1]);
    } else {
      my[i] += (10 + (in[i*2+1] - 'a'));
    }
  }
  
  double dk = double(1 << 28);
  int l = -1;
  rep (S,8) {
    int ar[3], temp = 0;
    rep (i,3) ar[i] = (S >> i & 1) ? 255 : 0 ;
    rep (i,3) {
      temp += (ar[i] - my[i]) * (ar[i] - my[i]);
    }
    if (dk > temp) {
      dk = temp;
      l = S;
    }
  }
  return name[l];
}

int main() {
  while (cin >> in) {
    if (in == "0") break;
    cout << solve() << endl;
  }
  return 0;
}