#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

const
char r[]=" rel=", n[]="nofollow"; 

int main(){
	int i,x,y,z,et,end,first,quote;
	char s[255],m[300];
	bool copy,rfound,nfound, done;
	ifstream fin ("DATA3.txt");
	ofstream fout ("OUT3.txt");
	for (i=0; i<5; i++){
		fin.getline(s, 255);
		memset(m,0,sizeof(m));
		et=0;
		end=0;
		quote=0;
		copy=false;
		rfound=false;
		nfound=false;
		done=false;
		for (x=0; x<strlen(s); x++){
			if (s[x+1] == r[1]){
				//cout<<s[x+1]<<endl;

				rfound=true;
				for (y=0; y<5; y++)
					if (s[x+y] != r[y]){
						//cout<<s[x+y]<<' ' <<r[y]<<endl;
						rfound=false;
					}
				y+=x+1;
				while ((s[y] != char(34)) && (rfound)){
					if (s[y] == n[0]){
						nfound=true;
						//cout<<"nofollow"<<endl;
						for (z=1; z<8; z++)
							if (s[y+z] != n[z]){
								//cout<<s[y+z]<<' '<<n[z]<<end;
								nfound=false;
							}
					}
					y++;
					//if (nfound)
						//rfound=false;
				}
			}
			
			if ((rfound) && (!nfound) && (s[x]==char(34))){
				quote++;
				if (quote == 2){
					/*y=x-1;
					while (s[y] != '<'){
						if (s[y] == n[7]){
							nfound=true;
							for (z=6; z >=0; z--)
								if (s[y-(7-z)] == n[z])
									nfound=false;
						}
						y--;
					}*/
					//if (!nfound){
					if (s[x-1] != char(34))
						m[end]=' ';
					strcat(m,n);
					end+=8;
					nfound=true;
					//}
				}
			}
			if ((!rfound) && (!nfound) &&  (s[x] == '>') && (et == 0) && (!done)){
				strcat(m,r);
				end+=5;
				m[end]=char(34);
				strcat(m,n);
				end+=9;
				m[end]=char(34);
				end++;
				rfound=true;
				nfound=true;
				done=true;
			}
			if (s[x] == '<') 
				copy=true;
			if (copy){
				m[end]=s[x];
				end++;
			}
			if (s[x] == '>'){
				et++;
				if (et == 2)
					copy=false;
				else
					first=end-1;
			}				
			
		}


		fout<<m<<endl;
	}
	return(0);
}

