\documentclass{article}
\usepackage{xcolor}
\newlength\mylinelength
\newlength\mylinethickness
\setlength\mylinethickness{2pt}
\newcommand*\LOWERLINE[2][cyan]{%
\settowidth\mylinelength{#2}%
\mbox{% this ensures the contents stay in one line
\makebox[0pt][l]{% this allows overprinting
\raisebox{-\mylinethickness}{% shift the rule below baseline
{\color{#1}\rule{\mylinelength}{\mylinethickness}}% the colored rule
}%
}%
#2%
}%
}%\LOWERLINE[color]{text}
\newcommand*\UPPERLINE[2][cyan]{%
\settowidth\mylinelength{#2}%
\mbox{% this ensures the contents stay in one line
\makebox[0pt][l]{% this allows overprinting
\raisebox{1.2ex}{% shift the rule above text
{\color{#1}\rule{\mylinelength}{\mylinethickness}}% the colored rule
}%
}%
#2%
}%
}%\UPPERLINE[color]{text}
\begin{document}
g\LOWERLINE{aa}tum y\LOWERLINE[red]{a}jnaay\UPPERLINE{a}...
\end{document}