A Classification of Finite Metahamiltonian $p$-Groups \thanks{This work was supported by NSFC (no. 11071150), by NSF of Shanxi Province (no. 2012011001-3) and Shanxi Scholarship Council of China (No. [2011]8-059). }
Xingui Fang
School of Mathematics Science
Beijing
100087 PR China
Department of Mathematics
Linfen
Shanxi
041004 PR China
A group is called metahamiltonian if all non-abelian subgroups of it are normal. This concept is a natural generation of Hamiltonian groups. In this paper, the properties of finite metahamiltonian $p$-groups are investigated, and a complete classification of finite metahamiltonian $p$-groups is given. \medskip \noindent{Keywords} Dedekindian groups, metahamiltonian groups, $\mathcal{A}_2$-groups, $\mathcal{T}_4$-groups \noindent{2000 Mathematics subject classification:} 20D15.
1310.5509.tex
\documentclass[11pt]{article}
\usepackage{amsthm,amsfonts,amsmath,amssymb}
%\include{PDF}
%\usepackage{showkeys}
\textheight 22.5 truecm \textwidth 14.5 truecm \hoffset -1.7
truecm \voffset -1.7 truecm
%\pagestyle{empty}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{defi}[thm]{Definition}
\newtheorem{prob}[thm]{Problem}
\newtheorem{rem}[thm]{Remark}
\newtheorem{exam}[thm]{Example}

\def\a{\alpha} \def\b{\beta} \def\g{\gamma} \def\d{\delta} \def\e{\varepsilon}
\def\r{\rho} \def\s{\sigma} \def\t{\tau} \def\om{\omega} \def\k{\kappa}
\def\th{\theta} \def\ld{\lambda} \def\ph{\varphi} \def\z{\zeta}
\def\D{\Delta} \def\Th{\Theta} \def\Ld{\Lambda}
\def\si{\Sigma} \def\O{\Omega}

\def\di{\bigm|} \def\lg{\langle} \def\rg{\rangle}
\def\edi{\bigm|\bigm|}
\def\f{\noindent}
\def\maxsgp{<\!\!\!\cdot\ }
\def\PSL{\hbox{\rm PSL}}
\def\SL{\hbox{\rm SL}} \def\PGL{\hbox{\rm PGL}}
\def\Hom{\hbox{\rm Hom}}
\def\End{\hbox{\rm End}}
\def\Aut{\hbox{\rm Aut\,}}
\def\Inn{\hbox{\rm Inn}}
\def\Syl{\hbox{\rm Syl}}
\def\Ker{\hbox{\rm Ker }}
\def\soc{\hbox{\rm soc}}
\def\Fix{\hbox{\rm Fix }}
\def\cay{\hbox{\rm Cay }}
\def\Cay{\hbox{\rm Cay }}
\def\Sab{\hbox{\rm Sab }}
\def\mod{\hbox{\rm mod }}
\def\Core{\hbox{\rm Core}}
\def\Cov{\hbox{\rm Cov}}
\def\demo{\f{\bf Proof}\hskip10pt}
\def\cha{\hbox{\rm\ char }}

\def\oa{\overline A} \def\og{\overline G} \def\oh{\overline H}
\def\ob{\overline B} \def\oc{\overline C} \def\oq{\overline Q}
\def\ok{\overline K} \def\ol{\overline L} \def\om{\overline M}
\def\on{\overline N} \def\op{\overline P} \def\os{\overline S}
\def\ot{\overline T} \def\ou{\overline U} \def\ov{\overline V}
\def\ow{\overline W} \def\ox{\overline X}


\def\qed{\hfill $\Box$}
\def\qqed{\hfill $\Box$\vspace{3mm}}
\def\Z{{\rm Z}}
\def\X{{\cal X}}
\def\Q{{\rm Q}}
\def\D{{\rm D}}
\def\SD{{\rm SD}}
\def\C{{\rm C}}
\def\M{{\rm M}}
\def\N{{\rm N}}
\def\lg{\langle}
\def\rg{\rangle}

\def\O{\Omega}

\newcommand{\pf}{\noindent {\bf Proof. \ }}
%\newcommand{\atilde}{\widetilde{\alpha}}

\def\rr#1{\item[{\rm (#1)}]}
%\def\rr#1{{\rm (#1)}}


%\def\M{\mathcal{M}$$}
%\def\D{\mathcal{D}$$}
\def\B{\mathcal{B}$$}
\def\A{\mathcal{A}$$}

\newcommand{\G}{\overline{G}}


\begin{document}
\title{A Classification of Finite Metahamiltonian $p$-Groups
\thanks{This work was supported by NSFC (no. 11071150),
by NSF of Shanxi Province (no. 2012011001-3) and Shanxi Scholarship
Council of China (No. [2011]8-059). }}
\author{Xingui Fang\\
School of Mathematics Science, Peking University\\
Beijing, 100087 PR China \\
Lijian An\thanks{Corresponding author. e-mail: anlj@sxnu.edu.cn}\\
Department of Mathematics, Shanxi Normal University\\
Linfen, Shanxi, 041004 PR China}


\date{}
\maketitle


\begin{abstract}
A group is called metahamiltonian if all non-abelian subgroups of it
are normal. This concept is a natural generation of Hamiltonian
groups. In this paper, the properties of finite metahamiltonian
$p$-groups are investigated, and a complete classification of finite
metahamiltonian $p$-groups is given.

\medskip
\noindent{\bf Keywords} Dedekindian groups, metahamiltonian groups,
$\mathcal{A}_2$-groups, $\mathcal{T}_4$-groups

\noindent{\it 2000 Mathematics subject classification:} 20D15.
\end{abstract}

\baselineskip=16pt


\section{Introduction}

A group is called Dedekindian if every subgroup of it is normal. In
1897, Dedekind classified finite Dedekindian group in \cite{Ded}. In
1933, Baer classified infinite Dedekindian group in \cite{Baer}. A
non-abelian Dedekindian group is also called Hamiltonian.

A non-abelian group is called metahamiltonian if all non-abelian
subgroups of it are normal. This concept is a natural generation of
Hamiltonian groups. In 1960's and 70's, many scholars researched
metahamilton groups. Romalis and Sesekin \cite{RS1,RS2,RS3}
investigated some properties on infinite metahamiltonian groups, and
Nagrebeckii\cite{Nag1, Nag2, Nag3} studied finite metahamiltonian
groups. Nagrebeckii \cite{Nag2} proved following theorem:

\begin{thm}\label{non-nilpotent}
Suppose that $G$ is a finite non-nilpotent group. Then $G$ is
metahamiltonian if and only is $G=SZ(G)$ where $S$ is one of the
following groups:

{\rm (1)} $P\rtimes Q$, where $P$ is an elementary $p$-group, $Q$ is
cyclic and $(p,|Q|)=1$;

{\rm (2)} $Q_8\rtimes Q$, where $Q$ is cyclic and $(|Q|,2)=1$;

{\rm (3)} $P\rtimes Q$, where $|P|=p^3, p\geq 5$, $Q$ is cyclic and
$(p,|Q|)=1$.
\end{thm}
In \cite{Nag2}, more detailed information on $S$ is given. Since a
nilpotent group is the direct product of its Sylow subgroups, by
above theorem, to study finite metahamiltonian groups, we only need
consider finite metahamiltonian $p$-groups, which is more complex
than the situation of non-nilpotent.

Metahamiltonian $p$-groups contain many important classes of
$p$-groups. For example, finite $p$-groups all of whose subgroups of
index $p^2$ are abelian, are metahamiltonian. All such groups are
determined, See \cite{BJ,Ber2,Dra,Kaz,She,ZSAX} for the
classification. Another example is finite $p$-groups all of whose
non-normal subgroups are cyclic. See \cite{Pas}. So, the
classification of metahamiltonian $p$-groups is an old problem. It
is concerned by many scholars. For example, this is a problem
proposed by Berkovich and Janko in their joint book \cite{Ber2}.

\medskip

{\bf Problem 768.} {\it Classify the $p$-groups all of whose
non-normal subgroups are abelian.}


\medskip

In this paper, the properties of finite metahamiltonian $p$-groups
are investigated, and a completed classification of finite
metahamiltonian $p$-groups is given.

\medskip

\noindent {\bf Main theorem(The classification of finite
metahamiltonian $p$-groups):} Suppose that $G$ is a finite
$p$-group. Then $G$ is metahamiltonian if and only if $G$ is
isomorphic to one of the following pairwise non-isomorphic groups:
\begin{enumerate}

\rr{A} groups with $|G'|=p$.

\rr{B} $\exp(G')=p$ and $c(G)=3$. In this case, $p$ is odd, $d(G)=2$
and all subgroups of index $p^2$ of $G$ are abelian.
\begin{enumerate}

\rr{Bi} $G$ has an abelian subgroup of index $p$.

\begin{enumerate}
\rr{B1} $\lg a_1,b\di
a_1^p=a_2^p=a_3^p=b^{p^m}=1,[a_1,b]=a_{2},[a_2,b]=a_3,[a_3,b]=1,[a_i,a_j]=1\rg,$
where $p\ge 5$ for $m=1$, $p\ge 3$ and $1\leq i,j\leq 3$;

\rr{B2} $\lg a_1,b\di
a_1^p=a_2^p=b^{p^{m+1}}=1,[a_1,b]=a_{2},[a_2,b]=b^{p^m},[a_1,a_2]=1\rg$,
where $p\ge 3$;

\rr{B3} $\lg a_1,b\di
a_1^{p^2}=a_2^p=b^{p^m}=1,[a_1,b]=a_{2},[a_2,b]=a_1^{\nu
p},[a_1,a_2]=1\rg,$ where $p\ge 3$ and $\nu=1$ or a fixed quadratic
non-residue modulo $p$;

\rr{B4} $\lg a_1,a_2,b\di
a_1^9=a_2^3=1,b^3=a_1^3,[a_1,b]=a_2,[a_2,b]=a_1^{-3},[a_2,a_1]=1\rg$.
\end{enumerate}

\rr{Bii} $G$ has no abelian subgroup of index $p$.

\begin{enumerate}
\rr{B5} $\lg a,b\di a^{p^2}=b^{p^2}=c^p=1,[a,b]=c,[c,a]=b^{\nu p},
[c,b]=a^{p}\rg$, where $p\ge 5$, $\nu$ is a fixed square non-residue
modulo $p$;

\rr{B6} $\lg a,b\di a^{p^2}=b^{p^2}=c^p=1,[a,
b]=c,[c,a]=a^{-p}b^{-lp},[c, b]=a^{-p}\rg$, where $p\ge 5$,
$4l=\rho^{2r+1}-1$, $r=1, 2, \dots, \frac{1}{2}(p-1)$, $\rho$ is the
smallest positive integer which is a primitive root modulo $p$;

\rr{B7} $\lg a, b\di a^9=b^9=c^3=1,[a,b]=c,[c,a]=b^{-3}, [c,
b]=a^3\rg$;

\rr{B8} $\lg a, b\di a^9=b^9=c^3=1, [a,b]=c, [c,a]=b^{-3}, [c,
b]=a^{-3}\rg$.
\end{enumerate}

\end{enumerate}
\rr{C} $c(G)=2$ and $G'\cong C_p^2$.
\begin{enumerate}
 \rr{C1} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$, $m_1\ge
  m_2=m_3+1$ and $A$ is abelian such that $\exp(A)\le p^{m_3}$;

  \rr{C2} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1}}=a_2^{ p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{\nu p^{m_2}}, [a_2,a_3]=1\rg$, $p>2$, $\nu$ is a fixed square non-residue modulo $p$, $m_1\ge
m_2=m_3+1$ or $m_1\ge m_2=m_3$ and $A$ is abelian such that
$\exp(A)\le p^{m_3}$;


  \rr{C3} $K\times A$, where $K=\lg a_1,a_2,a_3\di a_1^{p^{m_1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{kp^{m_2}}a_3^{-p^{m_3}}, [a_2,a_3]=1\rg$,
 $1+4k\not\in (F_p)^2$ for $p>2$, $k=1$ for $p=2$, $m_1\ge m_2=m_3$ and $A$ is abelian such that
$\exp(A)\le p^{m_3}$;


  \rr{C4} $K\times A$, where $K=\lg a_1,a_2,a_3\di
 a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=a_1^{p^{m_1}}, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$,
 $m_1>1$ for $p=2$, $m_1\ge m_2\ge m_3$, and $A$ is abelian such that
$\exp(A)\le p^{m_2}$;



 \rr{C5} $K\times A$, where $K=\lg a_1,a_2,a_3\di
 a_1^{p^{m_1+1}}=a_2^{p^{m_2}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_1^{p^{m_1}}, [a_2,a_3]=1\rg$,
$m_1\ge m_2=m_3+1$ and $A$ is abelian such that $\exp(A)\le
p^{m_3}$;

 \rr{C6} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=a_1^{p^{m_1}}\rg$,
$m_1-1=m_2\ge m_3$ and $A$ is abelian such that $\exp(A)\le
p^{m_2}$;

  \rr{C7} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=a_1^{\nu p^{m_1}}\rg$,
 $p>2$, $\nu$ is a fixed square non-residue modulo $p$,
$m_1-1=m_2\ge m_3$ or $m_1=m_2>m_3$,
 and $A$ is abelian such that
$\exp(A)\le p^{m_2}$;

  \rr{C8} $K\times A$, where $K=\lg a_1,a_2,a_3\di a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=a_1^{kp^{m_1}}a_2^{-p^{m_2}}\rg$,
 $1+4k\not\in (F_p)^2$ for $p>2$, $k=1$ for $p=2$, $m_1=m_2>m_3$ and $A$ is abelian such that
$\exp(A)\le p^{m_2}$;

  \rr{C9} $K\times A$, where $K=\lg a_1,a_2,b \di a_1^4=a_2^4=1,
b^2=a_1^2,[a_1,a_2]=1, [a_{1},b]=a_{2}^2, [a_{2},b]=a_{1}^2\rg$ and
$A$ is abelian such that $\exp(A)\le 2$;

  \rr{C10} $K\times A$, where $K=\lg a_1,a_2,b,d \di
a_1^4=a_2^4=1, b^2=a_1^2,d^2=a_{2}^2, [a_1,a_2]=1,
[a_{1},b]=a_{2}^2,
[a_{2},b]=a_{1}^2,[a_{1},d]=a_{1}^2,[a_{2},d]=a_{1}^2a_{2}^2,
[b,d]=1\rg$ and $A$ is abelian such that $\exp(A)\le 2$.

\end{enumerate}

\rr{D} $c(G)=2$ and $G'\cong C_p^3$.
\begin{enumerate}
\rr{D1} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{\nu p^{m_2}}, [a_2,a_3]=a_1^{p^{m_1}}\rg$,
 $p>2$, $\nu$ is a fixed square non-residue modulo $p$,
  $m_1=m_2=m_3+1$, and $A$ is abelian with $\exp(A)\le p^{m_3}$;

\rr{D2} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_1^{p^{m_1}}a_2^{lp^{m_2}},
  [a_2,a_3]=a_1^{p^{m_1}}\rg$, $1+4l\not\in (F_p)^2$ for $p>2$, $l=1$ for $p=2$,
  $m_1=m_2=m_3+1$, and $A$ is abelian with $\exp(A)\le p^{m_3}$;

\rr{D3} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{\nu p^{m_2}}, [a_2,a_3]=a_1^{p^{m_1}}\rg$,
$p>2$, $\nu$ is a fixed square non-residue modulo $p$,
  $m_1=m_2+1=m_3+1$, and $A$ is abelian with $\exp(A)\le p^{m_3}$;

\rr{D4} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{kp^{m_2}}a_3^{-p^{m_3}}, [a_2,a_3]=a_1^{p^{m_1}}\rg$,
$1+4k\not\in (F_p)^2$ for $p>2$, $k=1$ for $p=2$, $m_1=m_2+1=m_3+1$,
and $A$ is abelian with $\exp(A)\le p^{m_3}$;

\rr{D5} $K\times A$, where $K=\lg a_1,a_2,a_3\di
a_1^4=a_2^4=a_3^4=1, [a_1,a_2]=a_3^2, [a_1,a_3]=a_2^2a_3^2,
[a_2,a_3]=a_1^2a_2^2\rg$, and $A$ is abelian with $\exp(A)\le 2$.
\end{enumerate}

\rr{E} $G$ is metacyclic.

\begin{enumerate}
\rr{E1} $\langle a,b\di a^{p^{r+s+u}}=1,\
b^{p^{r+s+t}}=a^{p^{r+s}},\ a^b=a^{1+p^r}\rangle $, where $r\ge 1$,
$u\le r$ and $r+1\ge s+u\ge 2$. If $p=2$, then $r\ge 2$;

\rr{E2} $\lg a,b\di a^{2^{3}}=b^{2^m}=1, a^b=a^{-1}\rg$, where $m\ge
1$;

\rr{E3} $\lg a,b\di a^{2^{3}}=1, b^{2^m}=a^4, a^b=a^{-1}\rg$, where
$m\ge 1$;

\rr{E4} $\lg a,b\di a^{2^{3}}=b^{2^m}=1, a^b=a^3\rg$, where $m\ge
1$.
\end{enumerate}

\rr{F} $G$ is not metacyclic and $G'$ is cyclic and $|G'|\ge p^2$.
\begin{enumerate}
\rr{F1} $K\times A$, where $K=\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s}}=1,a^b=a^{1+p^{r}}\rg$, $u\le r$, $r+1>
s+u\ge 2$, and $A\ne 1$ is abelian such that $\exp(A)\le p^{
(r+1)-(s+u)}$;

\rr{F2} $K\times A$, where $K=\lg a,b\di
a^{p^{r+t+u}}=1,b^{p^{r}}=1,a^b=a^{1+p^{r+t}}\rg$, $t\ge 1$, $r\ge
u\ge 2$, and $A\ne 1$ is abelian such that $\exp(A)\le
p^{t+(r+1)-u}$;

\rr{F3} $K\times A$, where $K=\lg a,b\di
a^{p^{r+s}}=1,b^{p^{r+s+t}}=1,a^b=a^{1+p^{r}}\rg$, $t\ge 1$, $r+1>
s\ge 2$, and $A\ne 1$ is abelian such that $\exp(A)\le p^{(r+1)-s}$;

\rr{F4} $K\times A$, where $K=\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},a^b=a^{1+p^{r}}\rg$,
$stu\neq 0$, $r+1> s+u\ge 2$, and $A\ne 1$ is abelian such that
$\exp(A)\le p^{(r+1)-(s+u)}$;

\rr{F5} $(K\rtimes B)\times A$, where $K=\lg a,b\di
a^{p^{r+t+u}}=1,b^{p^{r}}=1,a^b=a^{1+p^{r+t}}\rg$, $B=\lg
b_1\rg\times\lg b_2\rg\times\dots\times\lg b_f\rg$ such that
$o(b_i)=p^{r_i}$, $[a,b_i]=a^{p^{r+t_i}}$, $[b,b_i]=1$,
$\max\{t,u-2\}<t_1<t_2<\dots<t_f<t+u$,
$r+t>r_1+t_1>r_2+t_2>\dots>r_f+t_f\ge t+u\ge t+2$, and $A$ is
abelian such that $\exp(A)\le p^{t+(r+1)-u}$.
\end{enumerate}
\rr{G} the type of $G'$ is $(p^\alpha,p)$ where $\alpha\ge 2$.

\begin{enumerate}
\rr{G1} $\lg a_1,a_2,a_3\di
 a_1^{p^{m_1+1+m_2}}=a_2^{p^{m_2+1}}=a_3^p=1,\
  [a_1,a_2]=a_1^{p^{m_1}},\  [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$,
  where $p>2$ and $m_1>
  m_2\ge 1$;

\rr{G2} $K\times A$, where $K=\lg a_1,a_2,a_3\di
 a_1^{p^{m_1+1+k}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=a_1^{p^{m_1}}, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$, $m_1\ge m_2\ge m_3$, $1\le
  k\le\min\{m_1-m_3,m_2-m_3+1,m_2-1\}$ and $A$ is abelian such that $\exp(A)\le p^{m_2-k}$.
\end{enumerate}
\end{enumerate}

\section{Preliminaries}

Let $G$ be a finite group. $G$ is said to be {\it minimal
non-abelian}, if $G$ is non-abelian, but every proper subgroup of
$G$ is abelian. A finite $p$-group $G$ is called an {\it
$\A_t$-group} if every subgroup of index $p^t$ of $G$ is abelian,
but there is at least one non-abelian subgroup of index $p^{t-1}$.
So ${\cal A}_1$-groups are just the minimal non-abelian $p$-groups.

\medskip

Let $G$ be a finite $p$-group. We define $\Lambda_1(G)=\{ a\in G\di
a^p=1 \}$, $V_1(G)=\{a^{p}\di a\in G \}$, $\Omega_1(G)=\lg
\Lambda_1(G) \rg=\lg a\in G\di a^{p}=1\rg$, and $\mho_1(G)=\lg
V_1(G)\rg=\lg a^{p}\di a\in G\rg$; $G$ is called {\it $p$-abelian}
if $(ab)^{p}=a^{p}b^{p}$ for all $a,b\in G$; We use $c(G)$ and
$d(G)$ to denote the nilpotency class and minimal number of
generators, respectively.

We use $M_p(m,n)$ to denote groups $\langle a, b \di
a^{p^m}=b^{p^n}=1, a^b=a^{1+p^{m-1}}\rangle$, where $m\geq 2$, and
use $M_p(m,n,1)$ to denote groups $\langle a, b, c \di
a^{p^m}=b^{p^n}=c^p=1, [a, b]=c, [c, a]=[c, b]=1 \rangle$, where
 $m+n\geq 3$ for $p=2$ and $m\geq n$. We can give a presentation of
minimal non-abelian $p$-groups as follows:

\begin{thm}\label{thm=Redei}{\rm (\cite {R})}{\rm(R\'edei)}
Let $G$ be a minimal non-abelian $p$-group. Then $G$ is $Q_8$,
$M_p(m,n)$, or $M_p(m,n,1)$.
\end{thm}

\medskip

We use $C_n$ and  $C_n^m$  to denote the cyclic group and the direct
product of $m$ cyclic groups of order $n$, respectively; and use
$H*K$ to denote a central product of $H$ and $K$. For undefined
notation and terminology the reader is referred to \cite{Hup}.

\medskip


We have the following information about minimal non-abelian
$p$-groups.

\begin{thm}\label{thm=inner abel properties}{\rm (\cite[Lemma 2.2] {Alj})}
Let $G$ be a finite $p$-group. Then the following conditions are
equivalent:
\begin{enumerate}
\rr1\ $G$ is an inner abelian $p$-group;

\rr2\ $d(G)=2$ and $|G'|=p$;

\rr3\ $d(G)=2$ and $Z(G)=\Phi (G)$.
\end{enumerate}
\end{thm}

Many scholars studied and classified $\mathcal{A}_2$-groups, see,
for example \cite{BJ,Ber2,Dra,Kaz,She,ZSAX}. We have following
Lemma.


\begin{lem}\label{A_2}{\rm(\cite{ZSAX})} Suppose that $G$ is an $\mathcal{A}_2$-group. Then $G$ is
one of the following groups:
\begin{enumerate}
\rr{I} $d(G)=2$ and $G$ has an abelian maximal subgroup.
\begin{enumerate}
\rr{1} $\lg a,b\di a^{8}=b^{2^m}=1, a^b=a^{-1}\rg$, where $m\ge 1$;

\rr{2} $\lg a,b\di a^{8}=b^{2^m}=1, a^b=a^{3}\rg$, where $m\ge 1$;

\rr{3} $\lg a,b\di a^{8}=1, b^{2^m}=a^{4}, a^b=a^{-1}\rg$, where
$m\ge 1$;

\rr{4} $\lg a_1,b\di
a_1^p=a_2^p=a_3^p=b^{p^m}=1,[a_1,b]=a_{2},[a_2,b]=a_3,[a_3,b]=1,[a_i,a_j]=1\rg,$
where $p\ge 5$ for $m=1$, $p\ge 3$ and $1\leq i,j\leq 3$;

\rr{5} $\lg a_1,b\di
a_1^p=a_2^p=b^{p^{m+1}}=1,[a_1,b]=a_{2},[a_2,b]=b^{p^m},[a_1,a_2]=1\rg$,
where $p\ge 3$;

\rr{6} $\lg a_1,b\di
a_1^{p^2}=a_2^p=b^{p^m}=1,[a_1,b]=a_{2},[a_2,b]=a_1^{\nu
p},[a_1,a_2]=1\rg,$ where $p\ge 3$ and $\nu=1$ or a fixed quadratic
non-residue modulo $p$.

\rr{7} $\lg a_1,a_2,b\di
a_1^9=a_2^3=1,b^3=a_1^3,[a_1,b]=a_2,[a_2,b]=a_1^{-3},[a_2,a_1]=1\rg$.

\end{enumerate}

\rr{II} $d(G)=3$, $|G'|=p$ and $G$ has an abelian maximal subgroup.

\begin{enumerate}

\rr{8} $\langle {a},{b},{x} \di {a}^4={x}^{2}=1,
{b}^2={a}^2=[{a},{b}], [{x},{a}]=[{x},{b}]=1 \rangle \cong Q_8
\times C_{2}$;

\rr{9}  $\langle {a}, {b},{x} \di {a}^{p^{n+1}}={b}^{p^m}={x}^{p}=1,
[{a},{b}]={a}^{p^{n}}, [{x},{a}]=[{x},{b}]=1\rangle\cong
M_p(n+1,m)\times C_{p}$;

\rr{10}  $\langle {a}, {b}, {c},{x} \di
{a}^{p^n}={b}^{p^m}={c}^{p}={x}^p=1, [{a},{b}]={c},
[{c},{a}]=[{c},{b}]=[{x},{a}]=[{x},{b}]=1\rangle\cong
M_p(n,m,1)\times C_{p}$, where $n\ge m$, and $n\ge 2$ if $p=2$;

\rr{11}  $\langle {a}, {b}, {x} \di {a}^4=1,
{b}^2={x}^{2}={a}^2=[{a},{b}], [{x},{a}]=[{x},{b}]=1\rangle \cong
Q_8 \ast C_{4}$;

\rr{12}  $\langle {a}, {b}, {x} \di
{a}^{p^n}={b}^{p^m}={x}^{p^{2}}=1, [{a},{b}]={x}^{p},
[{x},{a}]=[{x},{b}]=1 \rangle\cong M_p(n,m,1)\ast C_{p^{2}}$, where
$n\ge 2$ if $p=2$ and $n\ge m$.

\end{enumerate}


\rr{III} $d(G)=3$, $|G'|=p^2$ and $G$ has an abelian maximal
subgroup.


\begin{enumerate}

\rr{13} $\lg {a},{b},{c}\di {a}^{4}={b}^{4}=1,
{c}^2={a}^2{b}^2,[{a},{b}]={b}^2,[{c},{a}]={a}^2,[{c},{b}]=1\rg$;


\rr{14} $\lg {a},{b},{d}\di {a}^{p^{m}}={b}^{p^2}={d}^{p}=1,
[{a},{b}]={a}^{p^{m-1}},[{d},{a}]={b}^p,[{d},{b}]=1\rg$, where
$m\geq 3$ if $p=2$;

\rr{15} $\lg {a},{b},{d}\di {a}^{p^m}={b}^{p^2}={d}^{p^2}=1,
[{a},{b}]={d}^p,[{d},{a}]={b}^{jp},[{d},{b}]=1\rg$, where $(j,p)=1$,
$p>2$, $j$ is a fixed quadratic non-residue modulo $p$, and $-4j$ is
a quadratic non-residue modulo $p$;

\rr{16} $\lg {a},{b},{d}\di
 {a}^{p^m}={b}^{p^2}={d}^{p^2}=1,[{a},{b}]={d}^p,[{d},{a}]={b}^{jp}{d}^p,[{d},{b}]=1\rg$,
where if $p$ is odd, then $4j =1-\rho^{2r+1}$ with $1\le
r\le\frac{p-1}{2}$ and $\rho$ the smallest positive integer which is
a primitive root $(\mod p)$; if $p = 2$, then $j = 1$.

\end{enumerate}

\rr{IV} $d(G)=2$ and $G$ has no abelian maximal subgroup.


\begin{enumerate}

\rr{17} $\lg a, b\di a^{p^{r+2}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},[a,
b]=a^{p^r}\rg$, where $r\ge 2$ for $p=2$, $r\ge 1$ for $p\ge 3$,
$t\ge 0$, $0\le s\le 2$ and $r+s\ge 2$;

\rr{18} $\lg a,b\di a^{p^2}=b^{p^2}=c^p=1,[a,b]=c,[c,a]=b^{\nu p},
[c,b]=a^{p}\rg$, where $p\ge 5$, $\nu$ is a fixed square non-residue
modulo $p$;

\rr{19} $\lg a,b\di a^{p^2}=b^{p^2}=c^p=1,[a,
b]=c,[c,a]=a^{-p}b^{-lp},[c, b]=a^{-p}\rg$, where $p\ge 5$,
$4l=\rho^{2r+1}-1$, $r=1, 2, \dots, \frac{1}{2}(p-1)$, $\rho$ is the
smallest positive integer which is a primitive root modulo $p$;

\rr{20} $\lg a, b\di a^9=b^9=c^3=1,[a,b]=c,[c,a]=b^{-3}, [c,
b]=a^3\rg$;

\rr{21} $\lg a, b\di a^9=b^9=c^3=1, [a,b]=c, [c,a]=b^{-3}, [c,
b]=a^{-3}\rg$.

\end{enumerate}

\rr{V} $d(G)=3$ and $G$ has no abelian maximal subgroup.

\begin{enumerate}

\rr{22} $\lg a,b,d\di a^4=b^4=d^4=1, [a,b]=d^2, [d,a]=b^2d^2,
[d,b]=a^2b^2,[a^2,b]=[b^2,a]=1\rg$.

\end{enumerate}
\end{enumerate}

\end{lem}

Analyzing the group list in Lemma {\rm\ref{A_2}}, we have following
lemma.

\begin{lem}\label{A_2-property} Suppose that $G$ is an $\mathcal{A}_2$-group with order $p^n$.

{\rm (1)} $d(G)\le 3$ and $c(G)\le 3$;

{\rm (2)} If $d(G)=2$ and $\exp(G')=p$, then $c(G)=3$.

{\rm (3)} If $c(G)>2$ and $\exp(G')=p$, then $d(G)=2$ and $p$ is
odd.


\end{lem}

\begin{thm}{\rm (\cite[Statz 6.5]{Hup}}\label{thm=engle}
If $[x,y,y]=1$ for all $x,y\in G$, then $G$ is nilpotent and
$c(G)\le 3$. In addition, if $G$ has no element of order $3$, then
$c(G)\le 2$.
 \end{thm}
A finite $p$-group $G$ is called {\em metacyclic} if it has a cyclic
normal subgroup $N$ such that $G/N$ is also cyclic. It is obvious
that metacyclic $p$-groups are in $\B_p$.

In 1973 King\cite{king} classified metacyclic $p$-groups. In 1988
Newman and Xu (see \cite{NX,XZ1}) found new presentations for theses
groups. Theorem~\ref{metacyclic} is quoted from \cite{XZ1}.

\begin{thm}
\label{metacyclic classification} $(1)$ Any metacyclic $p$-group
$G$, $p$ odd, has the following presentation:
$$G=\langle a,b\di a^{p^{r+s+u}}=1,\ b^{p^{r+s+t}}=a^{p^{r+s}},\
a^b=a^{1+p^r}\rangle $$ where $r,\ s,\ t,\ u$ are non-negative
integers with $r\ge 1$ and $u\le r$. Different values of the
parameters $r,\ s,\ t$ and $u$ with the above conditions give
non-isomorphic metacyclic $p$-groups. It is denoted to $<r,s,t,u>_p$
in this paper.

$(2)$ Let $G$ be a metacyclic $2$-group. Then $G$ has one of the
following three kinds of presentations:

{\rm(I)} $G$ has a cyclic maximal subgroup. Hence $G$ is dihedral,
semi-dihedral, generalized quaternion, or an ordinary metacyclic
group presented by $G=\lg a,b\di
a^{2^n}=1,b^2=1,a^b=a^{1+2^{n-1}}\rg$.

{\rm(II)} Ordinary metacyclic $2$-groups: $G=\langle a,b\di
a^{2^{r+s+u}}=1,\ b^{2^{r+s+t}}=a^{2^{r+s}}, a^b=a^{1+2^r}\rangle $,
where $r,$ $s,$ $t,$ $u$ are non-negative integers with $r\ge 2$ and
$u\le r.$ It is denoted to $<r,s,t,u>_2$ in this paper.

{\rm(III)} Exceptional metacyclic $2$-groups: $G=\langle a,b\di
a^{2^{r+s+v+t'+u}}=1,\ b^{2^{r+s+t}}=a^{2^{r+s+v+t'}}$,
$a^b=a^{-1+2^{r+v}}\rangle  $, where $r,$ $s,$ $v,$ $t,$ $t',$ $u$
are non-negative integers with $r\ge 2,$ $t'\le r,$ $u\le 1$,
$tt'=sv=tv=0$, and  if $t'\ge r-1$ then $u=0$. Groups of different
types or of the same type but with different values of parameters
are not isomorphic to each other. It is denoted to
$<r,s,v,t,t',u>_2$ in this paper.
\end{thm}

\begin{lem}{\rm (\cite[$p_{27}$, Exercise 6 (a)]{Ber1})}
\label{number of abelian maximal subgroups} Let $G$ be a non-abelian
 $p$-group. Then the number of abelian subgroups of index $p$ in $G$ is $0,1$ or
$p+1$.

\end{lem}

\begin{lem}{\rm (\cite[$p_{136}$, Proposition 10.28]{Ber1})}
\label{generated by A_1 subgroups} A non-abelian
 $p$-group is generated by minimal non-abelian subgroups.
\end{lem}

\begin{lem}\label{phi(G')G_3}{\rm (\cite{Bla})}
\label{metacyclic} Suppose that $G$ is a finite $p$-group. Then $G$
is metacyclic if and only if $G/\Phi(G')G_3$ is metacyclic.
\end{lem}

\begin{lem}\label{metacyclic An}{\rm(\cite{Yak0}, Lemma J(i))}
Let $G$ be a metacyclic $p$-group. Then $G$ is an
$\mathcal{A}_n$-group if and only if $|G'|=p^n$.
\end{lem}


\begin{defi}
Let $V, W$ be finite-dimensional vector spaces over a field
$\mathbb{F}$ and let $f$ be a symplectic bilinear mapping of
$V\times V$ into $W$. For $v\in V$, define
$$v^\bot=\{u\di u\in V,f(u,v)=0 \}.$$
Then $v^\bot$ is an $\mathbb{F}$-subspace of $V$, and since $f$ is
symplectic, $\mathbb{F}v\subseteq v^\bot$.
\end{defi}

\begin{lem}{\rm \cite[Chapter VIII, Theorem 9.8]{Hup2}}\label{h&b}
Let $V, W$ be finite-dimensional vector spaces over a field
$\mathbb{F}$ and let $f$ be a symplectic bilinear mapping of
$V\times V$ into $W$. Suppose that $f(X, X) \subset f(V, V)$ for
every proper subspace $X$ of $V$. Then $V$ is spanned by
$$\{v\di v\in V,v^\bot=\mathbb{F}v \}.$$
\end{lem}

\begin{lem}{\rm \cite[Lemmma 5.3]{ADZ}}\label{skew-symmetric bilinear maps}
Let $V, W$ be finite-dimensional vector spaces over a field
$\mathbb{F}$ and let $f$ be a symplectic bilinear mapping of
$V\times V$ into $W$. Suppose that the dimension of $f(V,V)$ is $k$.

{\rm (1)} There is a subspace $S$ of $V$ such that $f(S,S)=f(V,V)$
 and the dimension of $S$ does not exceed $k+1$.

{\rm (2)} Let $k\ge 2$ and let $S$ be a $(k+1)$-dimensional subspace
of $V$ such that $f(S,S)=f(V,V)$. If $f(X,X)\subset f(S,S)=f(V,V)$
for every proper subspace $X$ of $S$, then $S$ has a $2$-dimensional
subspace $A$ such that $f(A,A)=0$.
\end{lem}

A finite p-group $G$ is said to be a $\mathcal{T}_4$-group if any
two noncommutative elements generate a minimal non-abelian groups of
order $p^4$. \cite{AP} classify $\mathcal{T}_{4}$-groups, see
Theorem \ref{m_31p}--\ref{n_21p and m_22p}.

\begin{thm}\label{m_31p}

Let $G$ be a non-abelian $\mathcal{T}$$_{4}$-group. If a subgroup of
$G$ is isomorphic to $M_p(3,1)$, then $G\cong M_p(3,1)\times
C_{p}^{n}$.
\end{thm}

\begin{thm}\label{N_21p}
Let $G$ be a non-abelian $\mathcal{T}$$_{4}$-group. If any two
noncommutative elements of $G$ generate $M_p(2,1,1)$, then $G\cong
H\times C_{p}^n$, where $H=K \rtimes \lg a\rg$ is a cyclic extension
of $K=\lg b_{1}\rg\times \lg b_{2}\rg\times \dots \times \lg
b_{k}\rg \times \lg c_{1}\rg\times \lg c_{2}\rg\times \dots \times
\lg c_{k}\rg\cong C_p^{2k}$ by $\lg a\rg$ with $a^{p^2}=1$ and
$b_{i}^{a}=b_{i}c_{i},c_{i}^{a}=c_{i}$ $(1\leq i\leq k)$.
\end{thm}


\begin{thm}\label{M_22p}
Let $G$ be a non-abelian $\mathcal{T}$$_{4}$-group. Suppose that any
two noncommutative elements of $G$ generate $M_{2,2,p}$, where
$p>2$. Then $G\cong H\times C_{p}^n$, where $H=K\rtimes\lg b \rg$ is
a cyclic extension of $K=\lg a_1\rg\times\lg a_2\rg\times\dots\lg
a_k\rg\cong C_{p^{2}}^{k}$ by $\lg b \rg$ with $o(b)={p^2}$ and
$a_i^b=a_i^{1+p}$ for $1\le i\le k$.
\end{thm}



\begin{thm}\label{M_222}
Let $G$ be a non-abelian $\mathcal{T}$$_{4}$-group. Suppose that any
two noncommutative elements of $G$ generate $M_{2,2,2}$, then $G$ is
one of the following non-isomorphic groups:
\begin{enumerate}

\rr1 $H\times C_{2}^n$, where $H=K\rtimes\lg b \rg$ is a cyclic
extension of $K=\lg a_1\rg\times\lg a_2\rg\times\dots\lg a_k\rg\cong
C_{4}^{k}$ by $\lg b \rg$ with $b^4=1$ and $a_i^b=a_i^{-1}$ $(1\le
i\le k)$;

\rr2 $H\times C_{2}^n$, where $H=\lg a_1,a_2,b \di a_1^4=a_2^4=1,
b^2=a_1^2,[a_1,a_2]=1, [a_{1},b]=a_{2}^2, [a_{2},b]=a_{1}^2\rg$;

\rr3 $H\times C_{2}^n$, where $H=\lg a_1,a_2,b,d \di a_1^4=a_2^4=1,
b^2=a_1^2,d^2=a_{2}^2, [a_1,a_2]=1, [a_{1},b]=a_{2}^2,
[a_{2},b]=a_{1}^2,[a_{1},d]=a_{1}^2,[a_{2},d]=a_{1}^2a_{2}^2,
[b,d]=1\rg$.
\end{enumerate}
\end{thm}

\begin{thm}\label{n_21p and m_22p}
Suppose that $G$ be a non-abelian $\mathcal{T}$$_{4}$-group, two
subgroups of $G$ are isomorphic to $M_p(2,2,1)$ and $M_p(2,2)$
respectively and no subgroup of $G$ is isomorphic to $M_p(3,1)$.
then $G\cong L\times C_p^n$, where $L$ is one of the following
groups:
\begin{enumerate}

\rr1 $\lg a,b,d\di a^{p^2}=b^{p}=d^{p^2}=1,
[a,b]=d^p,[d,a]=[d,b]=1\rg$;

\rr2 $\lg a,b,d\di a^{p^{2}}=b^{p^2}=d^{p}=1,
[a,b]=a^{p},[d,a]=b^p,[d,b]=1\rg$;

\rr3 $\lg a,b,d\di a^{p}=b^{p^2}=d^{p^2}=1, [a,b]=d^p,[d,a]=b^{-\nu
p},[d,b]=1\rg$, where $p$ is odd and $\nu$ is a fixed quadratic
non-residue modulo $p$;


\rr4 $\lg a,b,d\di
 a^{p}=b^{p^2}=d^{p^2}=1,[a,b]=d^p,[d,a]=b^{jp}d^p,[d,b]=1\rg$. If $p$ is odd,
 then
$4j=1-\rho^{2r+1}$, $1\le\rho\le\frac{p-1}{2}$, $\rho$ the smallest
positive integer which is a primitive root modulo $p$; If $p=2$,
then $j=1$.
\end{enumerate}

\end{thm}

\begin{cor}\label{t4} Suppose that $G$ is a finite metahamiltonian $p$-group such that $|G'|\ge p^2$. If $G\in\mathcal{T}_{4}$,
then $G$ is either a group of Type $(2)$--$(3)$ in Theorem
$\ref{M_222}$, or a group of Type $(2)$--$(4)$ in Theorem
$\ref{n_21p and m_22p}$.
\end{cor}


We need following Lemmas. Proofs are omitted.

\begin{lem}\label{lem=num p odd}
Suppose that $U=U(p^{n})$ is the multiplicative group containing of
all invertible elements of $\Bbb Z/p^{n}\Bbb Z$, where $p$ is an odd
prime and $n$ is a positive integer. That is,
$$U=\{x\in \Bbb Z/p^{n}\Bbb Z\mid(x,p)=1\}.$$
 Let $S(U)\in {\rm Syl}_p(U)$. Then
 $$S(U)=\{x\in U\mid x\equiv1\ (\mod p)\},$$
and $S(U)$ is cyclic with order $p^{n-1}$. $S_{i}(U)$ where $0\leq
i<n$, the unique subgroup of $S(U)$ of order $p^{i}$, is
 $$S_{i}(U)=\{x\in U\mid x\equiv1\ (\mod p^{n-i})\}.$$
\end{lem}

\begin{lem}\label{lem=num p 2}
Suppose that $U=U(2^{n})$ is the multiplicative group containing of
all invertible elements of $\Bbb Z/2^{n}\Bbb Z$, where $n\ge 2$ is a
positive integer. Then
$$\begin{array}{cl}
  U & =\lg -1\rg\times\lg 1+2^2\rg(\cong C_2\times C_{2^{n-2}}) \\
   & =\{ \varepsilon +i2^m\di \varepsilon=\pm 1, 2\le m\le n, 1\le i\le 2^{n-m}\ {\rm and }\ i\ {\rm is \ odd}\}
\end{array}$$
For $m<n$, the order of $\varepsilon+i2^m$ is $2^{n-m}$ and $\lg
\varepsilon+i2^m\rg=\lg \varepsilon+j2^m\rg$ for all odd $j$.
 \end{lem}

\begin{thm}\label{herit}
Let $G$ be a finite metahamiltonian $p$-group. Then sections of $G$
are all metahamiltonian.
\end{thm}


\begin{thm}\label{thm=pandun}
Let $G$ be a finite $p$-group. Then $G$ is metahamiltonian if and
only if every minimal non-abelian subgroup is normal in $G$.
\end{thm}


\begin{thm}\label{Closure of x}
Let $G$ be a finite metahamiltonian $p$-group. Then, for all $x\in
G$, $\lg x\rg^G$ is abelian or minimal non-abelian.
\end{thm}


\begin{thm}\label{thm=metahamilton p-gp G, c(G) is at most 3}
Let $G$ be a metahamiltonian $p$-group. Then $c(G)\le 3$. In
particular, $G$ is metabelian.
\end{thm}



\begin{thm}\label{G'<N}Let $G$ be a finite $p$-group. $G$ is metahamiltonian if and only if
$G'$ is contained in every non-abelian subgroup of $G$.
\end{thm}


\begin{lem}\label{lem=not contain metacyclic}
Suppose that $G$ is a finite metahamiltonian $p$-group which has
elementary abelian derived group. If $G$ is not an
$\mathcal{A}_2$-group, then $\mathcal{A}_2$-subgroups of $G$ have
nilpotency class $2$.
\end{lem}


\begin{thm}\label{thm=c=3 exp(G')=p} Suppose that $G$ is a finite
metahamiltonian $p$-group having an elementary abelian derived
group. If $c(G)=3$, then $G$ is an $\mathcal{A}_2$-group.
\end{thm}



\begin{cor}
\label{cor=c=3 exp(G')=p} Suppose that $G$ is a finite
metahamiltonian $p$-group having an elementary abelian derived
group. If $c(G)=3$, then $d(G)=2$ and $p$ is odd.
\end{cor}

\section{The classification of finite
metahamiltonian $p$-groups having an elementary abelian derived
groups}


\begin{thm}\label{thm=G'=p^2}Suppose that $G$ is a metahamilton $p$-group. If $G'\cong C_p^2$ and $c(G)=2$,
then $G$ is a group of Type $(C1)$--$(C10)$ in Main theorem.
\end{thm}
\demo  Let the type of $G/G'$ be $(p^{m_1},p^{m_2},\dots,p^{m_r})$,
where $m_1\ge m_2\ge\dots\ge m_r$, $G/G'=\lg a_1G'\rg\times\lg
a_2G'\rg\times\dots\times\lg a_rG'\rg$, where $o(a_iG')=p^{m_i}$,
$i=1,2,\dots,r$. Then $G=\lg a_1,a_2,\dots,a_r\rg$.

If $m_1=1$, then $G/G'$ is elementary abelian. By Theorem
\ref{G'<N}, $G'\le \lg x,y\rg$ for every non-commutative pair
$x,y\in G$ and hence $\lg x,y\rg$ is minimal no-abelian with order
$p^4$. It follows that $G\in\mathcal{T}_4$. By Corollary \ref{t4},
we get groups (C2)--(C4) for $m_1=m_2=m_3=1$ and (C9)--(C10). In the
following, we may assume that $m_1>1$.


 Let $i$ be the minimal integer such that
$a_i\not\in Z(G)$. That is, there exists $j>i$ such that
$[a_i,a_j]\neq 1$. If $i\neq 1$, then $a_1\in Z(G)$. Replacing $a_1$
with $a_1a_j$, we get $a_1\not\in Z(G)$. If $i=1$, then we also have
$a_1\not\in Z(G)$.

Let $j$ be the minimal integer such that $[a_1,a_j]\neq 1$. If
$j\neq 2$, then $[a_1,a_2]=1$. Replacing $a_2$ with $a_2a_j$, we get
$[a_1,a_2]\neq 1$. If $j=2$, then we also have $[a_1,a_2]\neq 1$.

Let $k$ be the minimal integer such that $[a_k,a_l]\not\in\lg
[a_1,a_2]\rg$. If $k>2$, then, for all integer $s$, we have
$[a_1,a_s]\in\lg [a_1,a_2]\rg$ and $[a_2,a_s]\in\lg [a_1,a_2]\rg$.
(1) If $[a_1,a_l]=1$, then, replacing $a_2$ with $a_2a_l$, we have
$[a_2,a_k]\not\in\lg [a_1,a_2]\rg$. (2) If
$[a_1,a_l]=[a_1,a_2]^\alpha$ where $(\alpha,p)=1$, then, letting
$[a_1,a_k]=[a_1,a_2]^\beta$ and replacing $a_2$ with
$a_2a_ka_l^{\alpha^{-1}\beta}$, we have $[a_2,a_l]\not\in\lg
[a_1,a_2]\rg$. Hence we may assume that $k\le 2$.

Let $l$ be the minimal integer such that $[a_k,a_l]\not\in\lg
[a_1,a_2]\rg$. If $l\neq 3$, then $[a_1,a_3]\in\lg [a_1,a_2]\rg$ and
$[a_2,a_3]\in \lg[a_1,a_2]\rg$. Replacing $a_3$ with $a_3a_l$, we
have $[a_k,a_3]\not\in\lg [a_1,a_2]\rg$. Hence we may assume that
$l=3$.

Let $K=\lg a_1,a_2,a_3\rg$. Then $|K'|=|G'|=p^2$ and $d(K)=3$. Since
$\Phi(G)\le Z(G)$, $K$ is one of the groups determined in
\cite{ALQZ}, Checking \cite[Table 4]{ALQZ}, $K$ is one of the groups
(C1)--(C8) in Main theorem. If $r=3$, then $G=K$. In the following
we may assume that $r\ge 4$.

\medskip

Case 1: $K$ is a group of Type (C1) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$ where $m_1\ge
  m_2=m_3+1$.

\medskip

Assume that $a_4^{p^{m_4}}=a_2^{\alpha p^{m_2}}a_3^{\beta p^{m_3}}$.
(1) If $m_3>1$ or $p>2$, then, replacing $a_4$ with $a_4a_2^{-\alpha
p^{m_2-m_4}}a_3^{-\beta p^{m_3-m_4}}$, we have $a_4^{p^{m_4}}=1$.
(2) If $m_3=1$ and $p=2$, then $m_2=2$ and
$(a_4a_2^{-2\alpha}a_3^{-\beta})^2=[a_3,a_4]^\beta$. (i) If
$[a_3,a_4]^\beta=1$, replacing $a_4$ with
$a_4a_2^{-2\alpha}a_3^{-\beta}$ we have $a_4^2=1$. (ii) If
$[a_3,a_4]^\beta\neq 1$, then $(a_4a_2^{-2\alpha})^2=a_3^2$. Let
$L=\lg a_4a_2^{-2\alpha},a_3\rg$. Since
$[a_4a_2^{-2\alpha},a_3]=[a_4,a_3]\neq 1$, we have $L\unlhd G$. It
follows that $a_2^4=[a_1,a_3]\in L$. Hence we may assume
$[a_3,a_4]=a_2^4a_3^{2\gamma}$. If $[a_3,a_4]=a_2^2a_3^2$, then $\lg
a_1a_4,a_3\rg$ is neither abelian nor normal, a contradiction. Hence
$[a_3,a_4]=a_2^4$. Replacing $a_4$ with $a_4a_2^{2(1-\alpha)}a_3$,
we also have $a_4^2=1$.

By above argument, we may assume that $a_4^{p^{m_4}}=1$. If
$[a_1a_3^i,a_4]\neq 1$, then $\lg a_1a_3^i,a_4\rg$ is neither
abelian nor normal, a contradiction. Hence $[a_1,a_4]=1$ and
$[a_3,a_4]=1$.

We claim that $[a_2,a_4]=1$. Otherwise, since $\lg a_2,a_4\rg$ is
not abelian, we have $\lg a_2,a_4\rg\unlhd G$. By Theorem
\ref{G'<N}, $a_3^{p^{m_3}}\in \lg a_2,a_4\rg$. Hence we may assume
that $[a_2,a_4]=a_2^{\alpha p^{m_2}}a_3^{\beta p^{m_3}}$ where
$(\beta,p)=1$. Let $P=\lg a_1^\beta
a_4,a_2a_3^{\beta^{-1}(\alpha+1)}\rg$. By calculation, $[a_1^\beta
a_4,a_2a_3^{\beta^{-1}(\alpha+1)}]=[a_1,a_2]^\beta[a_1,a_3]^{\alpha+1}[a_4,a_2]=a_3^{\beta
p^{m_3}}a_2^{(\alpha+1)p^{m_2}}a_2^{-\alpha p^{m_2}}a_3^{-\beta
p^{m_3}}=a_2^{p^{m_2}}=(a_2a_3^{\beta^{-1}(\alpha+1)})^{p^{m_2}}$.
Hence $P$ is neither abelian nor normal in $G$, a contradiction.

By similar argument, we may assume that $a_i^{p^{m_i}}=1$ where
$i=5,6,\dots,r$, and we have $[a_1,a_i]=[a_2,a_i]=[a_3,a_i]=1$
where $i=5,6,\dots,r$.

If $r\ge 5$, by similar argument, we have $[a_i,a_j]=1$, where $4\le
i<j\le r$. Hence we get a group of Type (C1) in Main theorem.

\medskip

Case 2: $K$ is a group of Type (C2) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1}}=a_2^{ p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{\nu p^{m_2}}, [a_2,a_3]=1\rg$ where $p>2$, $\nu$ is a fixed square non-residue modulo $p$ and $m_1\ge
m_2=m_3+1$ or $m_1\ge m_2=m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_2^{\alpha p^{m_2}}a_3^{\beta p^{m_3}}$.
Replacing $a_4$ with $a_4a_2^{-\alpha p^{m_2-m_4}}a_3^{-\beta
p^{m_3-m_4}}$, we have $a_4^{p^{m_4}}=1$. If $[a_1,a_4]\neq 1$, then
$\lg a_1,a_4\rg$ is neither abelian nor normal in $G$, a
contradiction. Hence $[a_1,a_4]=1$.

\medskip

Subcase 2.1: $m_2=m_3+1$.

\medskip

If $[a_3,a_4]\neq 1$, then $\lg a_1a_3,a_4\rg$ is neither abelian
nor normal in $G$, a contradiction. Hence $[a_3,a_4]=1$. We claim
that $[a_2,a_4]=1$. Otherwise, since $\lg a_2,a_4\rg$ is
non-abelian, we have $\lg a_2,a_4\rg\unlhd G$. By Theorem
\ref{G'<N}, $a_3^{p^{m_3}}\in \lg a_2,a_4\rg$. Hence we may assume
$[a_2,a_4]=a_2^{\alpha p^{m_2}}a_3^{\beta p^{m_3}}$ where
$(\beta,p)=1$. By calculation, $\lg a_1^\beta
a_4,a_2a_3^{\beta^{-1}\nu^{-1}(\alpha+1)}\rg$ is neither abelian nor
normal in $G$, a contradiction.

By similar argument, we may assume that $a_i^{p^{m_i}}=1$ where
$i=5,6,\dots,r$, and we have $[a_1,a_i]=[a_2,a_i]=[a_3,a_i]=1$ where
$i=5,6,\dots,r$.

If $r\ge 5$, by similar argument, we have $[a_i,a_j]=1$, where $4\le
i<j\le r$. Hence we get a group of Type (C2) with $m_1\ge m_2=m_3+1$
in Main theorem.

\medskip

Subcase 2.2: $m_2=m_3$.

\medskip

Assume that $[a_3,a_4]=a_2^{\alpha p^{m_2}}a_3^{\gamma p^{m_3}}$. If
$(\gamma,p)=1$, then $\lg a_3,a_4a_1^{\alpha\nu^{-1}}\rg$ is neither
abelian nor normal in $G$, a contradiction. Hence
$[a_3,a_4]=a_2^{\alpha p^{m_2}}$.

Assume that $[a_2,a_4]=a_2^{\gamma p^{m_2}}a_3^{\beta p^{m_3}}$. If
$(\gamma,p)=1$, then $\lg a_2,a_4a_1^{\beta}\rg$ is neither abelian
nor normal in $G$, a contradiction. Hence $[a_2,a_4]=a_3^{\beta
p^{m_3}}$.

Let $\delta=(\nu-1)^{-1}(\alpha-\beta)$. Then
$\delta\nu-\alpha=\delta-\beta$. By calculation,
$[a_2a_3,a_4a_1^\delta]=[a_2,a_4][a_2,a_1]^\delta[a_3,a_4][a_3,a_1]^\delta=a_3^{\beta
p^{m_3}}a_3^{-\delta p^{m_3}}a_2^{\alpha p^{m_2}}a_2^{-\delta\nu
p^{m_2}}=a_2^{(\alpha-\delta\nu)
p^{m_2}}a_3^{(\beta-\delta)p^{m_3}}=(a_2a_3)^{(\beta-\delta)p^{m_2}}$.
If $(a_2a_3)^{(\beta-\delta)p^{m_2}}\neq 1$, then $\lg
a_2a_3,a_4a_1^\delta \rg$ is neither abelian nor normal in $G$, a
contradiction. Hence $(a_2a_3)^{(\beta-\delta)p^{m_2}}=1$. That is,
$\beta=\delta$. It follows that $\alpha=\beta\nu$. If $(\beta,p)=1$,
then, replacing $a_4$ with $a_4^{-\beta^{-1}}$, we have
$[a_4,a_2]=a_3^{p^{m_3}}$ and $[a_4,a_3]=a_2^{\nu p^{m_2}}$.
Moreover, if $m_1=m_4$, then, replacing $a_4$ with $a_4a_1^{-1}$, we
have $[a_1,a_4]=[a_2,a_4]=[a_3,a_4]=1$.

By similar argument, we may assume that $a_i^{p^{m_i}}=1$ where
$i=5,6,\dots,r$, and we may assume that $[a_i,a_1]=1$,
$[a_i,a_2]=a_3^{p^{m_3}}$, $[a_i,a_3]=a_2^{\nu p^{m_2}}$ for
$m_1>m_i$ or $[a_1,a_i]=[a_2,a_i]=[a_3,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.

Let $i$ be the maximal integer such that $[a_i,a_2]\neq 1$. If
$i=1$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C2)
with $m_1\ge m_2=m_3$ in Main theorem. If $i>1$, then $m_1>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. If $m_1>m_2$,
then $\lg a_1a_2,a_i\rg$ is neither abelian nor normal in $G$, a
contradiction. Hence $m_1=m_2$. Let $J=\lg a_2,a_3,a_i^{-1}\rg$.
Then $J$
 is a group of Type (C7) in Main theorem. For $1\le k<i$ such
 that $[a_k,a_2]\neq 1$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $1\le k<i$. In
this case, $G\cong J\times A$ where $\exp(A)=p^{m_2}$. Hence we get
a group of Type (C7) with $m_1=m_2>m_3$ in Main theorem.

\medskip

Case 3: $K$ is a group of Type (C3) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_2^{kp^{m_2}}a_3^{-p^{m_3}},
  [a_2,a_3]=1\rg$ where
 $1+4k\not\in (F_p)^2$ for $p>2$, $k=1$ for $p=2$ and $m_1\ge
 m_2=m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_2^{\alpha p^{m_2}}a_3^{\beta p^{m_3}}$.

If $p>2$ or $m_2=m_3>1$, then, replacing $a_4$ with $a_4a_2^{-\alpha
p^{m_2-m_4}}a_3^{-\beta p^{m_3-m_4}}$, we have $a_4^{p^{m_4}}=1$. If
$p=2$ and $m_2=m_3=m_4=1$, then we claim that there exists an
involution in $\{ a_4,a_4a_2,a_4a_3,a_4a_2a_3\}$. Otherwise,
$a_4^2\ne 1,(a_4a_2)^2\ne 1$, $(a_4a_3)^2\ne 1$ and
$(a_4a_2a_3)^2\ne 1$. (1) If $a_4^2=a_2^2$, then, since
$(a_4a_2)^2=[a_4,a_2]\neq 1$, $L=\lg a_4,a_2\rg$ is not abelian. It
follows that $L\unlhd G$. By Theorem \ref{G'<N}, $a_3^2\in L$. Hence
we may assume that $[a_4,a_2]=a_3^2a_2^{2\alpha}$. If
$[a_4,a_2]=a_3^2a_2^2$, then $\lg a_1a_4,a_2\rg$ is neither abelian
nor normal in $G$, a contradiction. If $[a_4,a_2]=a_3^2$, then
$(a_4a_2)^2=a_3^2$. Since $(a_4a_2a_3)^2\ne 1$, we have
$[a_4a_2,a_3]=[a_4,a_3]=(a_4a_2a_3)^2\neq 1$. Since $M=\lg
a_4a_2,a_3\rg$ is non-abelian, we get $M\unlhd G$. By Theorem
\ref{G'<N}, $a_2^2\in M$.  Since $(a_4a_3)^2\ne 1$, we have
$[a_4,a_3]\neq a_2^2a_3^3$. Hence $[a_4,a_3]=a_2^2$. In this case,
$\lg a_1a_4a_2,a_3\rg$ is neither abelian nor normal in $G$, a
contradiction. (2) If $a_4^2=a_3^2$, then, since
$(a_4a_3)^2=[a_4,a_3]\neq 1$, $L=\lg a_4,a_3\rg$ is non-abelian. It
follows that $L\unlhd G$. By Theorem \ref{G'<N}, $a_2^2\in L$. Hence
we may assume that $[a_4,a_3]=a_2^2a_3^{2\alpha}$. If
$[a_4,a_3]=a_2^2$, then $\lg a_1a_4,a_3\rg$ is neither abelian nor
normal in $G$, a contradiction. Hence $[a_4,a_3]=a_2^2a_3^2$. Since
$(a_4a_2)^2=a_2^2a_3^2[a_4,a_2]=[a_4a_3,a_2a_3]\neq 1$, we have
$M=\lg a_4a_3,a_2a_3\rg$ is non-abelian. It follows that $M\unlhd
G$. By Theorem \ref{G'<N}, $a_2^2\in M$. Since $(a_4a_2a_3)^2\ne 1$,
we have $[a_4,a_2a_3]\ne a_2^2$. Hence $[a_4,a_2a_3]=a_3^2$. Then
$\lg a_1a_4a_3,a_2a_3\rg$ is neither abelian nor normal in $G$, a
contradiction. (3) If $a_4^2=a_2^2a_3^2$, then, since
$(a_4a_2a_3)^2=[a_4,a_2a_3]\neq 1$, $L=\lg a_4,a_2a_3\rg$ is
non-abelian. It follows that $L\unlhd G$. By Theorem \ref{G'<N},
$a_2^2\in L$. Hence we may assume that $[a_4,a_2a_3]=a_3^2$ or
$a_2^2$. If $[a_4,a_2a_3]=a_3^2$, then $\lg a_1a_4,a_2a_3\rg$ is
neither abelian nor normal in $G$, a contradiction.
 Hence $[a_4,a_2a_3]=a_2^2$. Since
$(a_4a_3)^2=a_2^2[a_4,a_3]=[a_4,a_2]\neq 1$, we have $M=\lg
a_4a_2a_3,a_2\rg$ is non-abelian. It follows that $M\unlhd G$. By
Theorem \ref{G'<N}, $a_3^2\in M$. Hence we may assume that
$[a_4,a_2]=a_3^2a_2^{2\alpha}$. Since $(a_4a_2)^2\ne 1$, we have
$[a_4,a_2]\ne a_3^2$. Hence $[a_4,a_2]=a_2^2a_3^2$. Then $\lg
a_1a_4a_2a_3,a_2\rg$ is neither abelian nor normal in $G$, a
contradiction.

By above argument, we may assume that $a_4^{p^{m_4}}=1$. If
$[a_1,a_4]\neq 1$, then $\lg a_1,a_4\rg$ is neither abelian nor
normal in $G$. Hence $[a_1,a_4]=1$.

We claim that $[a_3,a_4]\in\lg a_2^{kp^{m_2}}a_3^{-p^{m_3}}\rg$.
Otherwise, we may assume that
$[a_3,a_4]=(a_2^{kp^{m_2}}a_3^{-p^{m_3}})^\alpha a_3^{\gamma
p^{m_3}}$ where $(\gamma,p)=1$. By calculation, $\lg
a_3,a_4a_1^{\alpha}\rg$ is neither abelian nor normal in $G$, a
contradiction.

We claim that $[a_2,a_4]\in\lg a_3^{p^{m_3}}\rg$. Otherwise, we may
assume that $[a_2,a_4]=a_2^{\gamma p^{m_2}}a_3^{\beta p^{m_3}}$
where $(\gamma,p)=1$. By calculation, $\lg a_2,a_4a_1^{\beta}\rg$ is
neither abelian nor normal in $G$, a contradiction.

Let $\delta=k^{-1}((k+1)\alpha-\beta)$. Then
$k(\alpha-\delta)=\beta-\alpha$. By calculation,
$[a_2a_3,a_4a_1^\delta]=[a_2,a_4][a_2,a_1]^\delta[a_3,a_4][a_3,a_1]^\delta
%=a_3^{\beta p^{m_3}}a_3^{-\delta p^{m_3}}(a_2^{kp^{m_2}}a_3^{-p^{m_3}})^\alpha(a_2^{kp^{m_2}}a_3^{-p^{m_3}})^{-\delta} =a_2^{k(\alpha-\delta)
%p^{m_2}}a_3^{(\beta-\alpha)p^{m_3}}
=(a_2a_3)^{(\beta-\alpha)p^{m_2}}$. If $\beta\ne \alpha$, then $\lg
a_2a_3,a_4a_1^\delta \rg$ is neither abelian nor normal, a
contradiction. Hence $\beta=\alpha$. If $(\beta,p)=1$, then,
replacing $a_4$ with $a_4^{-\beta^{-1}}$, we have
$[a_4,a_2]=a_3^{p^{m_3}}$ and
$[a_4,a_3]=a_2^{kp^{m_2}}a_3^{-p^{m_3}}$. If $m_1=m_4$, then,
replacing $a_4$ with $a_4a_1^{-1}$, we have
$[a_1,a_4]=[a_2,a_4]=[a_3,a_4]=1$.

By similar argument as above, we may assume that $a_i^{p^{m_i}}=1$
where $i=5,6,\dots,r$, and we may assume that $[a_i,a_1]=1$,
$[a_i,a_2]=a_3^{p^{m_3}}$, $[a_i,a_3]=a_2^{kp^{m_2}}a_3^{-p^{m_3}}$
for $m_1>m_i$ or $[a_1,a_i]=[a_2,a_i]=[a_3,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.

Let $i$ be the maximal integer such that $[a_i,a_2]\neq 1$. If
$i=1$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C3)
in Main Theorm. If $i>1$, then $m_1>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. If $m_1>m_2$,
then $\lg a_1a_2,a_i\rg$ is neither abelian nor normal in $G$, a
contradiction. Hence $m_1=m_2$. Let $J=\lg a_2,a_3,a_i^{-1}\rg$.
Then $J$
 is a group of Type (C8) in Main theorem. For $1\le k<i$ such
 that $[a_k,a_2]\neq 1$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $1\le k<i$. In
this case, $G\cong J\times A$ where $\exp(A)=p^{m_2}$. Hence we get
a group of Type (C8) in Main theorem.

\medskip

Case 4: $K$ is a group of Type (C4) in Main Theorem. That is, $K=\lg
a_1,a_2,a_3\di
 a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=a_1^{p^{m_1}}, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=1\rg$
  where
 $m_1>1$ for $p=2$ and $m_1\ge m_2\ge m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}$.

If $p>2$ or $m_2>1$, then, replacing $a_4$ with $a_4a_1^{-\alpha
p^{m_1-m_4}}a_2^{-\beta p^{m_2-m_4}}$, we have $a_4^{p^{m_4}}=1$. If
$p=2$ and $m_2=m_3=m_4=1$, then $m_1>1$. We claim that there exists
an $x\in\{ a_4,a_4a_2\}$ such that $x^2\in \lg a_1^{2^{m_1}}\rg$.
Otherwise, $a_4^2=a_2^2$. Since $[a_4,a_2]=(a_4a_2)^2\not\in \lg
a_1^{2^{m_1}}\rg$, we have $\lg a_4,a_2\rg$ is non-abelian. It
follows that $\lg a_4,a_2\rg\unlhd G$. By Theorem \ref{G'<N},
$a_1^{2^{m_1}}\in \lg a_4,a_2\rg$. Hence
$[a_4,a_2]=a_1^{2^{m_1}}a_2^{2}$. Thus $\lg a_4a_2,
a_2a_1^{2^{m_1-1}}\rg$ is neither abelian nor normal in $G$, a
contradiction. Replacing $a_4$ with $x$ or $xa_1^{2^{m_1-1}}$, we
have $a_4^2=1$.

By above argument, we may assume that $a_4^{p^{m_4}}=1$. If
$[a_3,a_4]\neq 1$, then $\lg a_3,a_4\rg$ is neither abelian nor
normal in $G$. Hence $[a_3,a_4]=1$.

We claim that $[a_1,a_4]\in\lg a_2^{p^{m_2}}\rg$. Otherwise, we may
assume that $[a_1,a_4]=a_1^{\gamma p^{m_1}}a_2^{\alpha p^{m_2}}$
where $(\gamma,p)=1$. By calculation, $\lg a_1,a_4a_3^{-\alpha}\rg$
is neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_1,a_4]=a_2^{\alpha p^{m_2}}$.

We claim that $[a_2,a_4]\in\lg a_1^{p^{m_1}}\rg$. Otherwise, we may
assume that $[a_2,a_4]=a_2^{\gamma p^{m_2}}a_1^{\beta p^{m_1}}$
where $(\gamma,p)=1$. By calculation, $\lg a_1^{\beta
p^{m_1-m_2}}a_2^{\gamma},a_4a_3^{-\alpha}\rg$ is neither abelian nor
normal in $G$, a contradiction.

We claim that $[a_2,a_4]=1$. Otherwise, we may assume that
$[a_2,a_4]=a_1^{\beta p^{m_1}}$ where $(\beta,p)=1$. If $m_1>m_2$,
then $\lg a_1a_2, a_4a_3^{-\alpha}\rg$ is neither abelian nor normal
in $G$, a contradiction. If $m_1=m_2$, then $\lg a_1a_2,
a_4a_3^{\beta-\alpha}\rg$ is neither abelian nor normal in $G$, also
a contradiction.

If $m_3=m_4$, then, replacing $a_4$ with $a_4a_3^{-\alpha}$, we have
$[a_1,a_4]=1$. If $m_3>m_4$ and $[a_1,a_4]\neq 1$, then, by suitable
replacement, we may assume that $[a_1,a_4]=a_2^{p^{m_2}}$.

By similar argument as above, we may assume that $a_i^{p^{m_i}}=1$
where $i=5,6,\dots,r$, and we may assume that
$[a_2,a_i]=[a_3,a_i]=1$, and we may assume that
$[a_1,a_i]=a_2^{p^{m_2}}$ for $m_3>m_i$ or $[a_1,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.


Let $i$ be the maximal integer such that $[a_1,a_i]=a_2^{p^{m_2}}$.
If $i=3$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C4)
in Main theorem. If $i>3$, then $m_3>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. Let $J=\lg
a_1,a_2,a_i\rg$. Then $J$
 is a group of Type (C4) in Main theorem. For $3\le k<i$ such
 that $[a_1,a_k]=a_2^{p^{m_2}}$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $3\le k<i$. In
this case, $G\cong J\times A$ where $p^{m_i}<\exp(A)\le p^{m_2}$. We
also get a group of Type (C4) in Main theorem.


\medskip

Case 5: $K$ is a group of Type (C5) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di
 a_1^{p^{m_1+1}}=a_2^{p^{m_2}}=a_3^{p^{m_3+1}}=1,
  [a_1,a_2]=a_3^{p^{m_3}}, [a_1,a_3]=a_1^{p^{m_1}}, [a_2,a_3]=1\rg$
  where
$m_1\ge m_2=m_3+1$.

\medskip

Assume that $a_4^{p^{m_4}}=a_1^{\alpha p^{m_1}}a_3^{\beta p^{m_3}}$.

If $p>2$ or $m_3>1$, then, replacing $a_4$ with $a_4a_1^{-\alpha
p^{m_1-m_4}}a_3^{-\beta p^{m_3-m_4}}$, we have $a_4^{p^{m_4}}=1$. If
$p=2$ and $m_3=m_4=1$, then $m_1>1$. We claim that there exists an
$x\in\{ a_4,a_4a_3\}$ such that $x^2\in \lg a_1^{2^{m_1}}\rg$.
Otherwise, $a_4^2=a_3^2$. Since $[a_4,a_3]=(a_4a_3)^2\not\in \lg
a_1^{2^{m_1}}\rg$, we have $\lg a_4,a_3\rg$ is non-abelian. It
follows that $\lg a_4,a_3\rg\unlhd G$. By Theorem \ref{G'<N},
$a_1^{2^{m_1}}\in \lg a_4,a_3\rg$. Hence
$[a_4,a_3]=a_1^{2^{m_1}}a_3^{2}$. Thus $\lg a_4a_1^{2^{m_1-1}},
a_3a_1^{2^{m_1-1}}\rg\cong Q_8$ is neither abelian nor normal in
$G$, a contradiction. Replacing $a_4$ with $x$ or
$xa_1^{2^{m_1-1}}$, we have $a_4^2=1$.

By above argument, we may assume that $a_4^{p^{m_4}}=1$. If
$[a_2,a_4]\neq 1$, then $\lg a_2,a_4\rg$ is neither abelian nor
normal in $G$. Hence $[a_2,a_4]=1$. Similarly, we also have
$[a_3,a_4]=1$.

Assume that $[a_1,a_4]=a_1^{\alpha p^{m_1}}a_3^{\beta p^{m_3}}$. If
$(\alpha, p)=1$, then $\lg a_1, a_4a_2^{-\beta}\rg$ is neither
abelian nor normal in $G$, a contradiction. Hence
$[a_1,a_4]=a_3^{\beta p^{m_3}}$. If $(\beta,p)=1$, then $\lg a_1,
a_2^{-\beta}a_3a_4\rg$ is neither abelian nor normal in $G$, a
contradiction. Hence $[a_1,a_4]=1$.

By similar argument, we may assume that $a_i^{p^{m_i}}=1$ where
$i=5,6,\dots,r$, and we have $[a_1,a_i]=[a_2,a_i]=[a_3,a_i]=1$ where
$i=5,6,\dots,r$.

If $r\ge 5$, by similar argument, we have $[a_i,a_j]=1$, where $4\le
i<j\le r$. In this case, $G\cong J\times A$ where $\exp(A)=p^{m_3}$.
Hence we get a group of Type (C5) in Main theorem.

\medskip

Case 6: $K$ is a group of Type (C6) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=a_1^{p^{m_1}}\rg$
  where
$m_1-1=m_2\ge m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}$.

If $p>2$ or $m_2>1$, then, replacing $a_4$ with $a_4a_1^{-\alpha
p^{m_1-m_4}}a_2^{-\beta p^{m_2-m_4}}$, we have $a_4^{p^{m_4}}=1$. If
$p=2$ and $m_2=m_3=m_4=1$, then $m_1=2$. We claim that there exists
an $x\in\{ a_4,a_4a_2\}$ such that $x^2\in \lg a_1^{4}\rg$.
Otherwise, $a_4^2=a_2^2$. Since $[a_4,a_2]=(a_4a_2)^2\not\in \lg
a_1^{4}\rg$, we have $\lg a_4,a_2\rg$ is non-abelian. It follows
that $\lg a_4,a_2\rg\unlhd G$. By Theorem \ref{G'<N}, $a_1^{4}\in
\lg a_4,a_2\rg$. Hence $[a_4,a_2]=a_1^{4}a_2^{2}$. Thus $\lg
a_4a_1^2, a_2a_1^{2}\rg$ is neither abelian nor normal in $G$, a
contradiction. Replacing $a_4$ with $x$ or $xa_1^{2}$, we have
$a_4^2=1$.

By above argument, we may assume that $a_4^{p^{m_4}}=1$. If
$[a_3,a_4]\neq 1$, then $\lg a_3,a_4\rg$ is neither abelian nor
normal in $G$. Hence $[a_3,a_4]=1$.

We claim that $[a_1,a_4]\in\lg a_2^{p^{m_2}}\rg$. Otherwise, we may
assume that $[a_1,a_4]=a_1^{\gamma p^{m_1}}a_2^{\alpha p^{m_2}}$
where $(\gamma,p)=1$. By calculation, $\lg a_1,a_4a_3^{-\alpha}\rg$
is neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_1,a_4]=a_2^{\alpha p^{m_2}}$.

We claim that $[a_2,a_4]\in\lg a_1^{p^{m_1}}\rg$. Otherwise, we may
assume that $[a_2,a_4]=a_2^{\gamma p^{m_2}}a_1^{\beta p^{m_1}}$
where $(\gamma,p)=1$. By calculation, $\lg a_2,a_4a_3^{-\beta}\rg$
is neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_2,a_4]=a_1^{\beta p^{m_1}}$.

We claim that $\alpha\equiv \beta \ (\mod p)$. Otherwise, $\lg
a_1a_2, a_4a_3^{-\alpha}\rg$ is neither abelian nor normal in $G$, a
contradiction.

If $m_3=m_4$, then, replacing $a_4$ with $a_4a_3^{-\alpha}$, we have
$[a_1,a_4]=[a_2,a_4]=1$. If $m_3>m_4$ and $[a_1,a_4]\neq 1$, then,
by suitable replacement, we have $[a_1,a_4]=a_2^{p^{m_2}}$ and
$[a_2,a_4]=a_1^{p^{m_1}}$.

By similar argument as above, we may assume that $a_i^{p^{m_i}}=1$
where $i=5,6,\dots,r$, and we may assume that $[a_3,a_i]=1$, and we
may assume that $[a_1,a_i]=a_2^{p^{m_2}}$ and
$[a_2,a_i]=a_1^{p^{m_1}}$ for $m_3>m_i$ or $[a_1,a_i]=[a_2,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.


Let $i$ be the maximal integer such that $[a_1,a_i]=a_2^{p^{m_2}}$.
If $i=3$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C6)
in Main theorem. If $i>3$, then $m_3>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. Let $J=\lg
a_1,a_2,a_i\rg$. Then $J$
 is also a group of Type (C6) in Main theorem. For $3\le k<i$ such
 that $[a_1,a_k]=a_2^{p^{m_2}}$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $3\le k<i$. In
this case, $G\cong J\times A$ where $p^{m_i}<\exp(A)\le p^{m_2}$. We
also get a group of Type (C6) in Main theorem.


\medskip

Case 7: $K$ is a group of Type (C7) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}}, [a_2,a_3]=a_1^{\nu
  p^{m_1}}\rg$ where
 $p>2$, $\nu$ is a fixed square non-residue modulo $p$ and
$m_1-1=m_2\ge m_3$ or $m_1=m_2>m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}$.
Replacing $a_4$ with $a_4a_1^{-\alpha p^{m_1-m_4}}a_2^{-\beta
p^{m_2-m_4}}$, we have $a_4^{p^{m_4}}=1$. If $[a_3,a_4]\neq 1$, then
$\lg a_3,a_4\rg$ is neither abelian nor normal in $G$. Hence
$[a_3,a_4]=1$.

We claim that $[a_1,a_4]\in\lg a_2^{p^{m_2}}\rg$. Otherwise, we may
assume that $[a_1,a_4]=a_1^{\gamma p^{m_1}}a_2^{\alpha p^{m_2}}$
where $(\gamma,p)=1$. By calculation, $\lg a_1,a_4a_3^{-\alpha}\rg$
is neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_1,a_4]=a_2^{\alpha p^{m_2}}$.

We claim that $[a_2,a_4]\in\lg a_1^{p^{m_1}}\rg$. Otherwise, we may
assume that $[a_2,a_4]=a_2^{\gamma p^{m_2}}a_1^{\beta p^{m_1}}$
where $(\gamma,p)=1$. By calculation, $\lg
a_2,a_4a_3^{-\nu^{-1}\beta}\rg$ is neither abelian nor normal in
$G$, a contradiction. Hence we may assume that $[a_2,a_4]=a_1^{\beta
p^{m_1}}$.

We claim that $\alpha\nu\equiv \beta \ (\mod p)$. Otherwise, $\lg
a_1a_2, a_4a_3^{-\alpha}\rg$ is neither abelian nor normal in $G$, a
contradiction.

If $m_3=m_4$, then, replacing $a_4$ with $a_4a_3^{-\alpha}$, we have
$[a_1,a_4]=[a_2,a_4]=1$. If $m_3>m_4$ and $[a_1,a_4]\neq 1$, then,
by suitable replacement, we have $[a_1,a_4]=a_2^{p^{m_2}}$ and
$[a_2,a_4]=a_1^{\nu p^{m_1}}$.

By similar argument as above, we may assume that $a_i^{p^{m_i}}=1$
where $i=5,6,\dots,r$, and we may assume that $[a_3,a_i]=1$, and we
may assume that $[a_1,a_i]=a_2^{p^{m_2}}$ and $[a_2,a_i]=a_1^{\nu
p^{m_1}}$ for $m_3>m_i$ or $[a_1,a_i]=[a_2,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.


Let $i$ be the maximal integer such that $[a_1,a_i]=a_2^{p^{m_2}}$.
If $i=3$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C7)
in Main theorem. If $i>3$, then $m_3>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. Let $J=\lg
a_1,a_2,a_i\rg$. Then $J$
 is also a group of Type (C7) in Main theorem. For $3\le k<i$ such
 that $[a_1,a_k]=a_2^{p^{m_2}}$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $3\le k<i$. In
this case, $G\cong J\times A$ where $p^{m_i}<\exp(A)\le p^{m_2}$. We
also get a group of Type (C7) in Main theorem.

\medskip

Case 8: $K$ is a group of Type (C8) in Main theorem. That is, $K=\lg
a_1,a_2,a_3\di a_1^{p^{m_1+1}}=a_2^{p^{m_2+1}}=a_3^{p^{m_3}}=1,
  [a_1,a_2]=1, [a_1,a_3]=a_2^{p^{m_2}},
  [a_2,a_3]=a_1^{kp^{m_1}}a_2^{-p^{m_2}}\rg$ where
 $1+4k\not\in (F_p)^2$ for $p>2$, $k=1$ for $p=2$ and $m_1=m_2>m_3$.

\medskip

Assume that $a_4^{p^{m_4}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}$.
Replacing $a_4$ with $a_4a_1^{-\alpha p^{m_1-m_4}}a_2^{-\beta
p^{m_2-m_4}}$, we have $a_4^{p^{m_4}}=1$. If $[a_3,a_4]\neq 1$, then
$\lg a_3,a_4\rg$ is neither abelian nor normal in $G$. Hence
$[a_3,a_4]=1$.

We claim that $[a_1,a_4]\in\lg a_2^{p^{m_2}}\rg$. Otherwise, we may
assume that $[a_1,a_4]=a_1^{\gamma p^{m_1}}a_2^{\alpha p^{m_2}}$
where $(\gamma,p)=1$. By calculation, $\lg a_1,a_4a_3^{-\alpha}\rg$
is neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_1,a_4]=a_2^{\alpha p^{m_2}}$.

We claim that $[a_2,a_4]\in\lg a_1^{kp^{m_1}}a_2^{-p^{m_2}}\rg$.
Otherwise, we may assume that $[a_2,a_4]=a_2^{\gamma
p^{m_2}}(a_1^{kp^{m_1}}a_2^{-p^{m_2}})^{\beta}$ where
$(\gamma,p)=1$. By calculation, $\lg a_2,a_4a_3^{-\beta}\rg$ is
neither abelian nor normal in $G$, a contradiction. Hence we may
assume that $[a_2,a_4]=(a_1^{kp^{m_1}}a_2^{-p^{m_2}})^{\beta}$.

We claim that $\alpha\equiv \beta \ (\mod p)$. Otherwise, $\lg
a_1a_2, a_4a_3^{-\alpha}\rg$ is neither abelian nor normal in $G$, a
contradiction.

If $m_3=m_4$, then, replacing $a_4$ with $a_4a_3^{-\alpha}$, we have
$[a_1,a_4]=[a_2,a_4]=1$. If $m_3>m_4$ and $[a_1,a_4]\neq 1$, then,
by suitable replacement, we have $[a_1,a_4]=a_2^{p^{m_2}}$ and
$[a_2,a_4]=a_1^{kp^{m_1}}a_2^{-p^{m_2}}$.

By similar argument as above, we may assume that $a_i^{p^{m_i}}=1$
where $i=5,6,\dots,r$, and we may assume that $[a_3,a_i]=1$, and we
may assume that $[a_1,a_i]=a_2^{p^{m_2}}$ and
$[a_2,a_i]=a_1^{kp^{m_1}}a_2^{-p^{m_2}}$ for $m_3>m_i$ or
$[a_1,a_i]=[a_2,a_i]=1$.

If $r\ge 5$, then, by similar argument, we have $[a_i,a_j]=1$ where
$4\le i<j\le r$.


Let $i$ be the maximal integer such that $[a_1,a_i]=a_2^{p^{m_2}}$.
If $i=3$, then, for all $4\le j\le r$, we have
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$. Hence we get a group of Type (C8)
in Main Theorem. If $i>3$, then $m_3>m_i$ and
$[a_1,a_j]=[a_2,a_j]=[a_3,a_j]=1$ for all $i<j\le r$. Let $J=\lg
a_1,a_2,a_i\rg$. Then $J$
 is also a group of Type (C8) in Main theorem. For $3\le k<i$ such
 that $[a_1,a_k]=a_2^{p^{m_2}}$, replacing $a_k$ with $a_ka_i^{-1}$,
we have $[a_1,a_k]=[a_2,a_k]=[a_3,a_k]=1$ for all $3\le k<i$. In
this case, $G\cong J\times A$ where $p^{m_i}<\exp(A)\le p^{m_2}$. We
also get a group of Type (C8) in Main theorem. \qed


\begin{lem}\label{cor:|G'|=p^3 d(G)=3}Suppose that $G$ is a metahamilton $p$-group, $G'\cong C_p^3$, $c(G)=2$ and
$d(G)=3$. Then $G$ is one of the groups $($D1$)$--$($D5$)$ in Main
theorem, where $A=1$. If the type of $G/G'$ is
$(p^{m_1},p^{m_2},p^{m_3})$ where $m_1\ge m_2\ge m_3$, then
$G'=\Omega_1(V_{m_3}(G))$. Moreover, if $G/G'=\lg \bar{a}_1\rg\times
\lg \bar{a}_2\rg\times\lg \bar{a}_3\rg$, then $G'=\lg
a_1^{p^{m_1}},a_2^{p^{m_2}},a_3^{p^{m_3}}\rg$.
\end{lem}
\demo Since $c(G)=2$ and $G'\cong C_p^3$, $\Phi(G)\le Z(G)$. Hence
$G$ is one of the groups determined in \cite{QXA}. Checking
\cite[Table 8.1--8.4]{QXA}, $K$ is one of the groups (D1)--(D5) in
Main theorem, where $A=1$. If the type of $G/G'$ is
$(p^{m_1},p^{m_2},p^{m_3})$ where $m_1\ge m_2\ge m_3$, then it is
easy to check that $G'=\Omega_1(V_{m_3}(G))$. Moreover, if $G/G'=\lg
\bar{a}_1\rg\times \lg \bar{a}_2\rg\times\lg \bar{a}_3\rg$, then
$G'=\lg a_1^{p^{m_1}},a_2^{p^{m_2}},a_3^{p^{m_3}}\rg$.\qed


\begin{thm}\label{thm=G'=p^3}Suppose that $G$ is a metahamilton $p$-group. If $G'\cong C_p^3$ and $c(G)=2$,
then $G$ a group of Type $(D1)$--$(D5)$ in Main theorem.
\end{thm}

\demo   Let the type of $G/G'$ be $(p^{m_1},p^{m_2},\dots,p^{m_r})$,
where $m_1\ge m_2\ge\dots\ge m_r$, $G/G'=\lg a_1G'\rg\times\lg
a_2G'\rg\times\dots\times\lg a_rG'\rg$, where $o(a_iG')=p^{m_i}$,
$i=1,2,\dots,r$. Then $G=\lg a_1,a_2,\dots,a_r\rg$.

Since $G'\cong C_p^3$, it may be viewed as a $3$-dimensional linear
space over $\mathbb{F}=GF(p)$. Let $\overline{G}=G/\Phi(G)=\lg
\bar{a}_1,\bar{a}_2,\dots,\bar{a}_r\rg$. Then $\overline{G}$ may be
considered as a linear space over $\mathbb{F}$. Let $f$ be a mapping
from $\overline{G}\times \overline{G}$ to $G'$ such that
$f(\overline{g}, \overline{h})=[g,h]$ for all $\overline{g},
\overline{h} \in \overline{G}$. It follows from $c(G)=2$ that $f$ is
a symplectic bilinear mapping and $f(\overline{G},\overline{G})=G'$.
By Lemma \ref{skew-symmetric bilinear maps} (1), there is a subspace
$\overline{S}$ of $\overline{G}$ such that
$f(\overline{S},\overline{S})=G'$ and the dimension of
$\overline{K}$ does not exceed $4$.

We claim that there is a subspace $\overline{K}$ of $\overline{S}$
such that $f(\overline{K},\overline{K})=G'$ and the dimension of
$\overline{K}$ equal to $3$. Otherwise, the dimension of
$\overline{K}$ equal to $4$, and $f(\overline{X}, \overline{X})
\subset G'$ for every proper subspace $\overline{X}$ of
$\overline{S}$. We may assume that $\overline{S}$ is spanned by $
\bar{a}_{i}\bar{a}_{i+1}^{\alpha_{i+1}}\dots
\bar{a}_{r}^{\alpha_{r}}$,
$\bar{a}_j\bar{a}_{j+1}^{\beta_{j+1}}\dots
\bar{a}_{r}^{\beta_{r}}$,$\bar{a}_k\bar{a}_{k+1}^{\gamma_{k+1}}\dots
\bar{a}_{r}^{\gamma_{r}}$ and
$\bar{a}_l\bar{a}_{l+1}^{\delta_{l+1}}\dots
\bar{a}_{r}^{\delta_{r}}$ where $i>j>k>l$. Replacing $a_i,a_j,a_k$
and $a_l$ with $ a_{i}a_{i+1}^{\alpha_{i+1}}\dots
a_{r}^{\alpha_{r}}$, $a_ja_{j+1}^{\beta_{j+1}}\dots
a_{r}^{\beta_{r}}$,$a_ka_{k+1}^{\gamma_{k+1}}\dots
a_{r}^{\gamma_{r}}$ and $a_la_{l+1}^{\delta_{l+1}}\dots
a_{r}^{\delta_{r}}$ respectively, we get $\overline{S}=\lg
\bar{a}_i,\bar{a}_j,\bar{a}_k,\bar{a}_l\rg$. By Lemma \ref{h&b},
there exists $v\in \overline{S}$ such that $v^\perp=\mathbb{F}v$.
Without loss of generality, we may assume that $v=\bar{a}_i$. Let
$S=\lg a_i,a_j,a_k,a_l\rg$. Then $G'=S'=\lg
[a_i,a_j],[a_i,a_k],[a_i,a_l]\rg$. Since $\lg a_i,a_k\rg$ is
non-abelian, we have $\lg a_i,a_k\rg\unlhd G$. By Theorem
\ref{G'<N}, $G'\le \lg a_i,a_k\rg$. It follows that $G'=\lg
a_i^{p^{m_i}},a_k^{p^{m_k}},[a_i,a_k]\rg$. Similar reason gives that
$G'=\lg a_i^{p^{m_i}},a_l^{p^{m_l}},[a_i,a_l]\rg$. (1) If
$a_i^{p^{m_i}}\in\lg [a_i,a_k],[a_i,a_l]\rg$, then, letting
$a_i^{p^{m_i}}=[a_i,a_k]^\lambda[a_i,a_l]^\tau$, we have $\lg
a_i,a_k^\lambda a_l^\tau\rg$ is neither abelian nor normal in $G$, a
contradiction. (2) If $a_i^{p^{m_i}}\not\in\lg
[a_i,a_k],[a_i,a_l]\rg$, then $G'=\lg a_i^{p^{m_i}},
[a_i,a_k],[a_i,a_l]\rg$. Hence we may assume that
$[a_i,a_j]=a_i^{\theta}[a_i,a_k]^\lambda[a_i,a_l]^\tau$ where
$(\theta,p)=1$. By calculation, $\lg
a_i,a_ja_k^{-\lambda}a_l^{-\tau}\rg$ is neither abelian nor normal
in $G$, a contradiction.

Hence there is a subspace $\overline{K}$ of $\overline{G}$ such that
$f(\overline{K},\overline{K})=G'$ and the dimension of
$\overline{K}$ equal to $3$. We may assume that $\overline{K}$ is
spanned by $ \bar{a}_{i}\bar{a}_{i+1}^{\alpha_{i+1}}\dots
\bar{a}_{r}^{\alpha_{r}}$,
$\bar{a}_j\bar{a}_{j+1}^{\beta_{j+1}}\dots \bar{a}_{r}^{\beta_{r}}$
and $\bar{a}_k\bar{a}_{k+1}^{\gamma_{k+1}}\dots
\bar{a}_{r}^{\gamma_{r}}$ where $i>j>k$. Replacing $a_i,a_j$ and
$a_k$ with $a_{i}a_{i+1}^{\alpha_{i+1}}\dots a_{r}^{\alpha_{r}}$,
$a_ja_{j+1}^{\beta_{j+1}}\dots a_{r}^{\beta_{r}}$ and
$a_ka_{k+1}^{\gamma_{k+1}}\dots a_{r}^{\gamma_{r}}$ respectively, we
get $\overline{K}=\lg \bar{a}_i,\bar{a}_j,\bar{a}_k\rg$. Let $K=\lg
a_i,a_j,a_k\rg$. Then $K'=G'$. By Lemma \ref{cor:|G'|=p^3 d(G)=3},
$K'=\lg a_i^{p^{m_i}},a_j^{p^{m_j}},a_k^{p^{m_k}}\rg$.


We claim that $m_i=m_1$. Otherwise, $m_1>m_i\ge m_j\ge m_k$. Assume
that $a_1^{p^{m_1}}=a_i^{\alpha p^{m_i}}a_j^{\beta
p^{m_j}}a_k^{\gamma p^{m_k}}$. If $(\gamma,p)=1$, then, letting
$L=\lg a_i,a_j,a_k^{-\gamma}a_1^{p^{m_1-m_k}}\rg$, we have $L'=K'$.
By Lemma \ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_i^{p^{m_i}},a_j^{p^{m_j}},(a_k^{-\gamma}a_1^{p^{m_1-m_k}})^{p^{m_k}}\rg=\lg
a_i^{p^{m_i}},a_j^{p^{m_j}}\rg$, a contradiction. Hence
$a_1^{p^{m_1}}=a_i^{\alpha p^{m_i}}a_j^{\beta p^{m_j}}$. If
$(\beta,p)=1$, then, letting $L=\lg
a_i,a_k,a_j^{-\beta}a_1^{p^{m_1-m_j}}\rg$, we have $L'=K'$. By Lemma
\ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_i^{p^{m_i}},a_k^{p^{m_k}},(a_j^{-\beta}a_1^{p^{m_1-m_j}})^{p^{m_j}}\rg=\lg
a_i^{p^{m_i}},a_k^{p^{m_k}}\rg$, a contradiction. Hence
$a_1^{p^{m_1}}=a_i^{\alpha p^{m_i}}$. If $(\alpha,p)=1$, then,
letting $L=\lg a_j,a_k,a_i^{-\alpha}a_1^{p^{m_1-m_i}}\rg$, we have
$L'=K'$. By Lemma \ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_j^{p^{m_i}},a_k^{p^{m_k}},(a_i^{-\alpha}a_1^{p^{m_1-m_i}})^{p^{m_i}}\rg=\lg
a_j^{p^{m_i}},a_k^{p^{m_k}}\rg$, a contradiction. Hence
$a_1^{p^{m_1}}=1$. By Theorem \ref{G'<N}, $[a_1,a_i]=[a_1,a_j]=1$.
Similar reason gives that $[a_1a_k,a_i]=[a_1a_k,a_j]=1$. It follows
that $[a_k,a_i]=[a_k,a_j]=1$, also a contradiction. Hence we get
$m_1=m_i$. Without loss of generality, we may assume that $i=1$.
That is, $K=\lg a_1,a_j,a_k\rg$


We claim that $m_j=m_2$. Otherwise, $m_2>m_j\ge m_k$. Assume that
$a_2^{p^{m_2}}=a_1^{\alpha p^{m_1}}a_j^{\beta p^{m_j}}a_k^{\gamma
p^{m_k}}$. If $(\gamma,p)=1$, then, letting $L=\lg
a_1,a_j,a_k^{-\gamma}a_2^{p^{m_2-m_k}}\rg$, we have $L'=K'$. By
Lemma \ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_1^{p^{m_1}},a_j^{p^{m_j}},(a_k^{-\gamma}a_2^{p^{m_2-m_k}})^{p^{m_k}}\rg=\lg
a_1^{p^{m_1}},a_j^{p^{m_j}}\rg$, a contradiction. Hence
$a_2^{p^{m_2}}=a_1^{\alpha p^{m_1}}a_j^{\beta p^{m_j}}$. If
$(\beta,p)=1$, then, letting $L=\lg
a_1,a_k,a_j^{-\beta}a_1^{p^{m_2-m_j}}\rg$, we have $L'=K'$. By Lemma
\ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_1^{p^{m_1}},a_k^{p^{m_k}},(a_j^{-\beta}a_2^{p^{m_2-m_j}})^{p^{m_j}}\rg=\lg
a_1^{p^{m_1}},a_k^{p^{m_k}}\rg$, a contradiction. Hence
$a_2^{p^{m_2}}=a_1^{\alpha p^{m_1}}$. Replacing $a_2$ with
$a_2a_1^{-\alpha p^{m_1-m_2}}$, we have $a_2^{p^{m_2}}=1$. By
Theorem \ref{G'<N}, $[a_2,a_1]=[a_2,a_k]=1$. Similar reason gives
that $[a_2a_j,a_1]=[a_2a_j,a_k]=1$. It follows that
$[a_j,a_1]=[a_j,a_k]=1$, also a contradiction. Hence we get
$m_2=m_j$. Without loss of generality, we may assume that $j=2$.
That is, $K=\lg a_1,a_2,a_k\rg$.


We claim that $m_k=m_3$. Otherwise, $m_3>m_k$. Assume that
$a_3^{p^{m_3}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}a_k^{\gamma
p^{m_k}}$. If $(\gamma,p)=1$, then, letting $L=\lg
a_1,a_2,a_k^{-\gamma}a_3^{p^{m_3-m_k}}\rg$, we have $L'=K'$. By
Lemma \ref{cor:|G'|=p^3 d(G)=3}, $L'=\lg
a_1^{p^{m_1}},a_2^{p^{m_2}},(a_k^{-\gamma}a_3^{p^{m_3-m_k}})^{p^{m_k}}\rg=\lg
a_1^{p^{m_1}},a_2^{p^{m_2}}\rg$, a contradiction. Hence
$a_3^{p^{m_3}}=a_1^{\alpha p^{m_1}}a_2^{\beta p^{m_2}}$. Replacing
$a_3$ with $a_3a_1^{-\alpha p^{m_1-m_3}}a_2^{-\beta p^{m_2-m_3}}$,
we have $a_3^{p^{m_3}}=1$. By Theorem \ref{G'<N},
$[a_3,a_1]=[a_3,a_2]=1$. Similar reason gives that
$[a_3a_k,a_1]=[a_3a_k,a_2]=1$. It follows that
$[a_k,a_1]=[a_k,a_2]=1$, also a contradiction. Hence we get
$m_3=m_k$. Without loss of generality, we may assume that $k=3$.
That is, $K=\lg a_1,a_2,a_3\rg$.

If $r=3$, then, by Lemma \ref{cor:|G'|=p^3 d(G)=3}, $G=K$ is one of
the groups (D1)--(D5) in Main theorem. In the following we may
assume that $r\ge 4$.

By Lemma \ref{cor:|G'|=p^3 d(G)=3}, there exits $x\in K$ such that
$a_i^{p^{m_i}}=x^{p^{m_3}}$ for $i>3$. By Theorem \ref{G'<N},
$[a_i,x]=1$. Replacing $a_i$ with $a_ix^{-p^{m_3-m_i}}$, we have
$a_i^{p^{m_i}}=1$. By Theorem \ref{G'<N}, $a_i\in Z(G)$. Hence we
get groups (D1)--(D5) in Main theorem.\qed
\section{The classification of finite
metahamiltonian $p$-groups whose derived groups are not elementary
abelian}
\begin{thm} \label{thm=d(G)=2--metacyclic}Suppose that $G$ is a finite metahamilton $p$-group. If $d(G)=2$ and $\exp(G')>p$,
then $G$ is metacyclic.
\end{thm}
\demo Assume that $G=\lg a,b\rg$ is a counterexample with minimal
order. By Lemma \ref{metacyclic}, $\og:=G/\Phi(G')G_3$ is not
metacyclic. Since $|{\og}'|=p$, ${\og}$ is minimal non-abelian. By
Theorem \ref{thm=Redei}, ${\og}\cong \M_p(n,m,1)$. That is, we may
assume that $\og=\lg \bar{a},\bar{b}\di
\bar{a}^{p^n}=\bar{b}^{p^m}=\bar{c}^p=1,[\bar{a},\bar{b}]=\bar{c},[\bar{c},\bar{a}]=[\bar{c},\bar{b}]=1\rg$.
Since $\lg\bar{a}^p,\bar{b}\rg$, $\lg\bar{b}^p,\bar{a}\rg$,
$\lg(\bar{a}\bar{b})^p,\bar{a}\rg$ and
$\lg(\bar{a}\bar{b})^p,\bar{b}\rg$ are not normal in $\og$, We have
$\lg a^p,b,\Phi(G')G_3\rg$, $\lg b^p,a,\Phi(G')G_3\rg$, $\lg
(ab^p),a,\Phi(G')G_3\rg$ and $\lg (ab)^p,b,\Phi(G')G_3\rg$ are not
normal in $G$ and hence they are all abelian. Then we have
$\Phi(G')G_3\le Z(G)$ and
$$[a^p,b]=[b^p,a]=[(ab)^p,a]=[(ab)^p,b]=1\eqno(*)$$

If $p=2$, then $(ab)^2=a^2b^2[a,b]$. By $(*)$, $[a,b]\in Z(G)$.
Hence $G'=\lg [a,b]\rg$. By $(*)$, $[a,b]^2=[a^2,b]=1$, which is
contrary to $\exp(G')>2$.

If $p>2$, then, by calculation, we have $[a,b,a]^p=[a^p,b,a]=1$ and
$[a,b,b]^p=[a^p,b,b]=1$. It follows that $\exp(G_3)\le p$. By $(*)$,
$[a,b]^p=[a^p,b]=1$, which is contrary to $\exp(G')>p$.\qed

\begin{thm}\label{metacyclic metahamilton}Suppose that $G$ is a metacyclic $p$-group and $|G'|\ge p^2$.
If $G$ is metahamiltonian, then $G$ is a group of Type
$(E1)$--$(E4)$ in Main Theorem.
\end{thm}

\demo Case 1: $p>2$ or $G$ is an ordinary metacyclic $2$-group. That
is, $G=\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},a^b=a^{1+p^r}\rg$, where
$r\ge1$, $u\le r$. If $p=2$, then $r\ge 2$.

Since $|G'|\ge p^2$, we have $s+u\ge 2$. We only need to prove that
$r+1\ge s+u$. Otherwise, $r+1<s+u$. By calculation, $[a^{p^{r+1}},
b]=a^{-p^{r+1}}(a^{p^{r+1})})^b=a^{p^{2r+1}}\neq 1$. It follows that
$H=\lg a^{p^{r+1}}, b\rg$ is not abelian and hence $H\unlhd G$. By
Theorem \ref{G'<N}, $G'\le H$, a contradiction.

Hence $r+1\ge s+u$ and $G$ is a group of Type (E1) in Main theorem.

\medskip

Case 2: $p=2$ and $G$ is not an ordinary metacyclic $2$-group.

Let $o(a)=2^n$ and $H=\lg a^{2^{n-2}},b\rg$. Since $H'=\lg
a^{2^{n-1}}\rg$, $H$ is not abelian. It follows that $H\unlhd G$. By
Theorem \ref{G'<N}, $a^2\in H$. Hence $n\le 3$ and $|G'|=4$. By
Lemma \ref{metacyclic An}, $G\in\mathcal{A}_2$. By Lemma \ref{A_2},
we get groups of (E2)--(E4) in Main theorem. \qed


\begin{thm}\label{thm=G'=C_p^n}Suppose that $G$ is a metahamilton $p$-group and $G$ is not metacyclic.
If $|G'|\ge p^2$ and $G'$ is cyclic, then $G$ is  a group of Type
$(F1)$--$(F5)$ in main Theorem.
\end{thm}
\demo By Theorem \ref{thm=d(G)=2--metacyclic}, $d(G)>2$. Let $G'=\lg
c\rg$, the type of $G/G'$ be $(p^{m_1},p^{m_2},\dots,p^{m_w})$ where
$m_1\ge m_2\ge\dots\ge m_w$ and $G/G'=\lg a_1G'\rg\times\lg
a_2G'\rg\times\dots\times\lg a_wG'\rg$ where $o(a_iG')=p^{m_i}$,
$i=1,2,\dots,w$. Then $G=\lg a_1,a_2,\dots,a_w\rg$.

Let $i$ be the minimal integer such that $a_i\not\in
C_G(G/\mho_1(G'))$. Then there exists $j>i$ such that $G'=\lg
[a_i,a_j]\rg$. If $i\neq 1$, then $a_1\in C_G(G/\mho_1(G'))$.
Replacing $a_1$ with $a_1a_j$, we have $G'=\lg a_1,a_i\rg$.

Let $j$ be the minimal integer such that $G'=\lg [a_1,a_j]\rg$. If
$j\neq 2$, then $[a_1,a_2]\in\mho_1(G')$. Replacing $a_2$ with
$a_2a_j$, we have $G'=\lg [a_1,a_2]\rg$.

Let $K=\lg a_1,a_2\rg$. By Theorem \ref{thm=d(G)=2--metacyclic}, $K$
is metacyclic. Hence $K$ is one of the groups in Theorem
\ref{metacyclic metahamilton}. That is, $K$ is one of the groups
(E1)--(E4) in Main theorem.

\medskip

Step 1: We claim that $K$ is one of the groups of Type (E1) in Main
theorem.

\medskip

If not, then we may assume that $K=\lg a,b\rg$ satisfying the
relations of Type (E2)--(E4) in Main Theorem. That is,
$a^{2^3}=1,b^{2^m}\in K_3=\lg a^4\rg, [a,b]\in\lg a^2\rg\setminus
\lg a^4\rg$ and $G'=K'=\lg a^2\rg$, $m_3=m_4=\dots=m_w=1$.

Case 1: $a_3^2\in K_3$ and $[a_3,b]\in K_3$.

If $[a_3,b]=a^4$, then $\lg a_3,b\rg$ is neither abelian nor normal
in $G$, a contradiction. If $[a_3,b]=1$, then $\lg a_3a^2,b\rg$ is
neither abelian nor normal in $G$, a contradiction.

Case 2: $a_3^2\in K_3$ and $[a_3,b]\equiv a^2 \ (\mod K_3)$.

If $[a_3,a]\equiv a^2 \ (\mod K_3)$, then $(a_3a)^2\in K_3$ and
$[a_3a,b]\in K_3$. Replacing $a_3$ with $a_3a$, it is reduced to
Case 1. Hence we may assume that $[a_3,a]\in K_3$. Since
$[a_3,a^2]=[a_3,a]^2=1$, we have $[a_3,G']=1$. By calculation,
$1=[a_3^2,b]=[a_3,b]^2[a_3,b,a_3]=[a_3,b]^2$. Hence $[a_3,b]\in
K_3$, a contradiction.

Case 3: $a_3^2\equiv a^2 \ (\mod K_3)$.

If $[a_3,a]\in K_3$, then, replacing $a_3$ with $a_3a$, it is
reduced to Case 1 or Case 2. Hence we may assume that $[a_3,a]\equiv
a^2\ (\mod K_3)$. Since $a_3^2\equiv a^2\ (\mod K_3)$, we have
$[a_3^2,b]=[a^2,b]=a^4$. It follows that $[a_3,b]\equiv a^2\  (\mod
K_3)$. Since $(a_3a)^2\equiv a^2\  (\mod K_3)$, similar reason as
above gives that $[a_3a,b]\equiv a^2\  (\mod K_3)$. Hence $[a,b]\in
K_3$, a contradiction.

\medskip

Step 2: By suitable replacement, we have $a_i^{p^{m_i}}=1$, where
$3\le i\le w$. Moreover, $[a_i,a_j]=1$ for all $3\le i,j\le w$.

\medskip

By Step 1, $K\cong <r,s,t,u>_p$ where $r\ge 1$, $u\le r$ and $r+1\ge
s+u$. If $p=2$, then $r\ge 2$. Assume that $K=\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},a^b=a^{1+p^r}\rg$.

\medskip

 Let $L=\lg a,a_i\rg$ and $x_i\in L$ such that $L=\lg
a,x_i\rg$ and $\lg x_i\rg\cap\lg a\rg$ has minimal order. We claim
that $x_i^{p^{m_i}}=1$. Otherwise, we may assume that $\lg
x_i\rg\cap \lg a\rg=\lg a^{p^\alpha}\rg$ and $\lg [x_i,a]\rg=\lg
a^{p^\beta}\rg$ where $\alpha\ge r$ and $\beta\ge r$. Then there
exist integers $y$ and $z$ such that $(yz,p)=1$,
$x_i^{p^{m_i}}=a^{yp^{\alpha}}$ and $[x_i,a]=a^{zp^{\beta}}$. By
calculation,
$(x_ia^{-yp^{\alpha-m_i}})^{p^{m_i}}=x_i^{p^{m_i}}[x_i,a^{yp^{\alpha-m_i}}]^{p^{m_i}\choose
2}[x_i,a^{yp^{\alpha-m_i}},x_i]^{p^{m_i}\choose
3}a^{-yp^{\alpha}}=a^{yzp^{\alpha+\beta-m_i}{p^{m_i}\choose
2}}[a^{yzp^{\alpha+\beta-m_i}{p^{m_i}\choose 3}},x_i]$. Noting that
$\beta\ge r\ge 2$ for $p=2$, we have
$(x_ia^{-yp^{\alpha-m_i}})^{p^{m_i}}\in\lg a^{p^{\alpha+1}}\rg$,
which is contrary to the choice of $x_i$. Replacing $a_i$ with
$x_i$, we have $a_i^{p^{m_i}}=1$ where $3\le i\le w$. For $3\le
i,j\le w$, since $G'\not\le \lg a_i,a_j\rg$, Theorem \ref{G'<N}
gives that $[a_i,a_j]=1$.

\medskip

Step 3: $K$ is one of the following groups:
\begin{enumerate}
\rr{A} $\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s}}=1,a^b=a^{1+p^{r}}\rg$, where $r\ge 2$
for $p=2$ and $r+1\ge s+u\ge 2$;

\rr{B} $\lg a,b\di
a^{p^{r+t+u}}=1,b^{p^{r}}=1,a^b=a^{1+p^{r+t}}\rg$, where $t\ge 1$
and $r\ge u\ge 2$;

\rr{C} $\lg a,b\di
a^{p^{r+s}}=1,b^{p^{r+s+t}}=1,a^b=a^{1+p^{r}}\rg$, where $r\ge 2$
for $p=2$, $t\ge 1$ and $r+1\ge s\ge 2$;

\rr{D} $\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},a^b=a^{1+p^{r}}\rg$, where
$r\ge 2$, $stu\neq 0$ and $r+1\ge s+u\ge 2$.
\end{enumerate}

\medskip

Assume that $K=\lg a,b\di
a^{p^{r+s+u}}=1,b^{p^{r+s+t}}=a^{p^{r+s}},a^b=a^{1+p^r}\rg$. If
$t=0$, then we have $(ba^{-1})^{p^{r+s}}=1$ for $p>2$ and
$(ba^{2^u-2^{r-1}-1})^{2^{r+s}}=1$ for $p=2$. Replacing $b$ with
$ba^{-1}$ or $ba^{2^u-2^{r-1}-1}$ respectively, we get a group of
Type (A). In the following we may assume that $t\ge 1$. If $s=0$,
then $(a^{-1}b^{p^t})^{p^r}=1$. Replacing $a$ and $b$ with $b$ and
$a^{-1}b^{p^t}$ respectively, we get a group of Type (B). If $u=0$,
then we get a group of Type (C). If $su\neq 0$, then we get a group
of Type (D).

\medskip

Step 4: Determine $G$ in which $K$ is a direct factor. That is,
$G=K\times A$.

\medskip

It is easy to see that $A$ is abelian.

Case 1: $K$ is a group of Type (A) in Step 3.

Let $d\in A$ and $o(d)=p^e$. By calculation,
$[a^{p^{s+u-1}}d,b]=a^{p^{r+s+u-1}}\neq 1$. It follows that
$a^{p^r}\in \lg (a^{p^{s+u-1}}d)^{p^e}\rg=\lg a^{p^{e+s+u-1}}\rg$.
Hence $e+s+u-1\le r$. By the arbitrariness of $d$, we get
$\exp{A}\le p^{(r+1)-(s+u)}$. Since $G$ is not metacyclic, we have
$A\ne 1$. It follows that $r+1>s+u$. Hence we get a group of Type
(F1) in Main theorem.

Case 2: $K$ is a group of Type (B) in Step 3.

Let $d\in A$ and $o(d)=p^e$. By calculation,
$[a^{p^{u-1}}d,b]=a^{p^{r+t+u-1}}\neq 1$. It follows that
$a^{p^{r+t}}\in \lg (a^{p^{u-1}}d)^{p^e}\rg=\lg a^{p^{e+u-1}}\rg$.
Hence $e+u-1\le r+t$. By the arbitrariness of $d$, we get
$\exp{A}\le p^{t+(r+1)-u}$. Hence $G$ is a group of Type (F2) in
Main theorem.

Case 3: $K$ is a group of Type (C) or (D) in Step 3.

Let $d\in A$ and $o(d)=p^e$. By calculation,
$[a^{p^{s+u-1}}d,b]=a^{p^{r+s+u-1}}\neq 1$. It follows that
$a^{p^r}\in \lg (a^{p^{s+u-1}}d)^{p^e}\rg=\lg a^{p^{e+s+u-1}}\rg$.
Hence $e+s+u-1\le r$. By that arbitrariness of $d$, we
get$\exp{A}\le p^{(r+1)-(s+u)}$. Since $G$ is not metacyclic, we
have $A\ne 1$. It follows that $r+1>s+u$. Hence we get a group of
Type (F3) or (F4) in Main theorem.

\medskip

Step 5: Determine $G$ in which $K$ is not a direct factor.

\medskip

Let $G=H\times A$, where $K<H$ and $H$ has no direct factor. By Step
2, we may assume that $H=K\rtimes B$ where $B=\lg b_1\rg\times\lg
b_2\rg\times\dots\times\lg b_f\rg$ such that $o(b_i)=p^{r_i}$, $r\ge
r_1\ge r_2\ge\dots\ge r_f$.

We claim that $K$ is neither a group of Type (C) nor a group of Type
(D). Otherwise, by calculation, $\lg ab^{-p^t}\rg\cap \lg a\rg=1$.
Since $G'\not\le \lg ab^{-p^t},b_i\rg$, Theorem \ref{G'<N} gives
that $[ab^{-p^t},b_i]=1$. Similar reason gives that $[b,b_i]=1$.
Hence $H=K\times B$, which is contrary to the choice of $H$.

If $K$ is a group of Type (A), then we claim that $s=0$. Otherwise,
by calculation, $\lg ab \rg\cap\lg a\rg\le\lg a^{p^{r+1}}\rg$. Since
$G'\not\le \lg ab,b_i\rg$, Theorem \ref{G'<N} gives that
$[ab,b_i]=1$. Similar reason gives that $[b,b_i]=1$. Hence
$H=K\times B$, which is contrary to the choice of $H$.

By above argument, we may assume that $K=\lg a,b\di
a^{p^{r+t+u}}=1,b^{p^{r}}=1,a^b=a^{1+p^{r+t}}\rg$, where $t\ge 0$
and $r\ge u\ge 2$. Since $G'\not\le \lg b,b_i\rg$, Theorem
\ref{G'<N} gives that $[b,b_i]=1$.

Let $j$ be the minimal positive integer such that $[a,b_i]$ has
maximal order. We may assume that $j=1$, replacing $b_1$ with
$b_1b_j$ when it is necessary. Similarly, we may assume that $\lg
[a,b_1]\rg\ge\lg [a,b_2]\rg\ge\dots\ge\lg [a,b_f]\rg$.

Assume that $[a,b_i]=a^{\gamma_ip^{r+t_i}}$ where $(\gamma_i,p)=1$.
Then $t\le t_1\le t_2\le\dots\le t_f$. Note that
$a^b=a^{1+\gamma_ip^{r+t_i}}$. By Lemma \ref{lem=num p odd} and
\ref{lem=num p 2}, there exists positive integer $w$ such that
$(1+\gamma_ip^{r+t_i})^j\equiv 1+p^{r+t_i} \ (\mod p^{r+t+u})$.
Replacing $b_i$ with $b_i^w$, we have $[a,b_i]=a^{p^{r+t_i}}$.

Case 1: $t_1>t$.

If $t_2=t_1$, then $b_1b_2^{-1}$ is a direct factor of $H$, a
contradiction. Similarly, we have $t<t_1<t_2<\dots<t_f$. If
$(b_1b^{-p^{t_1-t}})^{p^{r_1}}=1$, then $b_1b^{-p^{t_1-t}}$ is a
direct factor of $H$, a contradiction. Hence
$(b_1b^{-p^{t_1-t}})^{p^{r_1}}\neq 1$. It follows that
$b^{p^{r_1+t_1-t}}\neq 1$. Hence $r_1+t_1-t<r$, and we have
$r-r_1>t_1-t>0$. Similarly, we have $r_i+t_i>r_{i+1}+t_{i+1}$. By
Lemma \ref{lem=num p odd} and \ref{lem=num p 2}, in the
multiplicative group containing of all invertible elements of $\Bbb
Z/p^{r+t+u}\Bbb Z$, the order of $1+p^{r+t_f}$ is $p^{t+u-t_f}$.
Since $[a,b_f^{p^{r_f}}]=1$, we have
$a^{b_f^{p^{r_f}}}=a^{(1+p^{r+t_f})^{p^{r_f}}}=a$. It follows that
$r_f\ge t+u-t_f$. That is, $t_f+r_f\ge t+u$.

By calculation, $\lg ba^{p^{t-t_1+u-1}}\rg\cap\lg a\rg=\lg
(ba^{p^{t-t_1+u-1}})^{p^r}\rg=\lg a^{p^{r+t-t_1+u-1}}\rg$. Let
$N=\lg ba^{p^{t-t_1+u-1}},b_1\rg$. Since
$[ba^{p^{t-t_1+u-1}},b_1]=a^{p^{r+t+u-1}}\neq 1$, $N$ is not
abelian. By Theorem \ref{G'<N}, $G'\le N$. It follows that
$r+t-t_1+u-1\le r+t$. That is, $t_1\ge u-1$.

Finally, by similar argument as Step 4, we have $\exp{A}\le
p^{t+(r+1)-u}$. Hence we get a group of Type (F5) in Main Theorem.
In this case, $\exp{A}\le p^r$.

Case 2: $t_1=t$.

Let $h$ be the maximal positive integer such that $t_h=t$ and
$\tilde{K}=\lg a,b_h\rg$. Then $\tilde{K}=\lg a,b_h\di
a^{p^{r_h+t+(r-r_h)+u}}=1,b_h^{p^{r_h}}=1,a^{b_h}=a^{1+p^{r_h+t+(r-r_h)}}\rg$.
Let $r'=r_h$ and $t'=t+(r-r_h)$. Then $\tilde{K}=\lg a,b_h\di
a^{p^{r'+t'+u}}=1,b_h^{p^{r'}}=1,a^{b_h}=a^{1+p^{r'+t'}}\rg$.
Replacing $b,b_1,\dots,b_{h_1}$ with
$bb_h,b_1b_h^{-1},\dots,b_{h-1}b_h^{-1}$ respectively, we have that
$b,b_1,\dots,b_{h-1}$ are direct factors of $G$. Replace $A$ with
$A\times\lg b\rg\times\lg b_1\rg\times\dots\times\lg b_{h-1}\rg$. If
$h=f$, then $G=\tilde{K}\times A$. By similar argument as Step 4, we
have $\exp{A}\le p^{t'+(r'+1)-u}$. Hence we get a group of Type (F2)
in Main Theorem.

In the following, we may assume that $h<f$. Let $f'=f-h$. For $1\le
i\le f'$, let $b_i'=b_{h+i}$ and $t_i'=t_{h+i}$. Let $\tilde{B}=\lg
b_1'\rg\times\dots\lg b_{f'}'\rg$,
$\tilde{H}=\tilde{K}\rtimes\tilde{B}$. Then $\tilde{H}$ has no
director factor and $t_1'>t'$. By similar argument as Case 1, we get
a group of Type (F5) in Main Theorem. \qed




\begin{thm}\label{thm=G'=C_p^n*c_p} Suppose that $G$ is a finite metahamilton $p$-group. If $\exp(G')>p$ and $G'$ is not cyclic,
then $G$ is a group of Type $(G1)$--$(G2)$ in Main theorem.
\end{thm}
\demo Let $H\le G$ such that $d(H)=2$ and $\exp(H')>p$. By Theorem
\ref{thm=d(G)=2--metacyclic}, $H$ is metacyclic. By Theorem
\ref{G'<N}, $G'<H$ and hence $G'$ is metacyclic.

Let $N=\mho_1(G')$ and $\bar{G}=G/N$. Then $\bar{G}'\cong C_p^2$. By
Theorem \ref{thm=d(G)=2--metacyclic}, $d(G)>2$ and hence
$d(\bar{G})>2$. By Corollary \ref{cor=c=3 exp(G')=p},
$c(\bar{G})=2$. Hence $\bar{G}$ is a group in Theorem
\ref{thm=G'=p^2}. That is, $\bar{G}$ is a group of Type (C1)--(C10)
in Main theorem.

Suppose that $\bar{G}$ is a group of Type (C1) in Main theorem. That
is, $\bar{G}=\bar{K}\times \bar{A}$, where $\bar{K}=\lg
\bar{a}_1,\bar{a}_2,\bar{a}_3\di
\bar{a}_1^{p^{m_1}}=\bar{a}_2^{p^{m_2+1}}=\bar{a}_3^{p^{m_3+1}}=1,
  [\bar{a}_1,\bar{a}_2]=\bar{a}_3^{p^{m_3}}, [\bar{a}_1,\bar{a}_3]=\bar{a}_2^{p^{m_2}},
  [\bar{a}_2,\bar{a}_3]=1\rg$, $m_1\ge m_2=m_3+1$,
  $\bar{A}$ is abelian such that $\exp(\bar{A})\le p^{m_3}$. Then $G'=\lg [a_1,a_2],[a_1,a_3],
  \mho_1(G')\rg=\lg [a_1,a_2],[a_1,a_3]\rg=\lg a_2^{p^{m_2}},a_3^{p^{m_3}}\rg$.
  Since $\lg
  \bar{a}_1,\bar{a}_2\rg$ and $\lg\bar{a}_1,\bar{a}_3\rg$ are not metacyclic,
we get that $\lg a_1,a_2\rg$ and $\lg a_1,a_3\rg$ are not
metacyclic. By Theorem \ref{thm=d(G)=2--metacyclic}, $[a_1,a_2]^p=1$
and $[a_1,a_3]^p=1$. Moreover, $\exp(G')=p$, a contradiction.

Similarly, $\bar{G}$ is not a group of Type (C2)--(C3) and
(C5)--(C8) in Main theorem.

Suppose that $\bar{G}$ is a group of Type (C9) in Main theorem. That
is, $\bar{G}=\bar{K}\times \bar{A}$, where $\bar{K}=\lg
\bar{a}_1,\bar{a}_2,\bar{b} \di \bar{a}_1^4=\bar{a}_2^4=1,
\bar{b}^2=\bar{a}_1^2,[\bar{a}_1,\bar{a}_2]=1,
[\bar{a}_{1},\bar{b}]=\bar{a}_{2}^2,
[\bar{a}_{2},\bar{b}]=\bar{a}_{1}^2\rg$ and
  $\bar{A}$ is abelian such that $\exp(\bar{A})\le
  2$. Then $G'=\lg [a_1,b],[a_2,b],
  \mho_1(G')\rg=\lg a_1^2,a_2^2\rg$ and $\mho_1(G')=\lg
  a_1^4,a_2^4\rg$.
Let $M$ be a maximal subgroup of $\mho_1(G')$ such that $M\unlhd G$.
Then we may assume that $M=\lg e,
  \mho_2(G')\rg$, $[a_1,a_2]\equiv e^i \
(\mod M)$, $b^2\equiv a_1^2e^j \ (\mod M)$ and $[a_1,b]\equiv
a_2^2e^k \ (\mod M)$. It follows from $[a_1,a_2]\equiv e^i \ (\mod
M)$ that $[a_1^2,a_2]\equiv [a_1,a_2^2]\equiv 1 \ (\mod M)$. It
follows from $b^2\equiv a_1^2e^j \ (\mod M)$ that $[a_1^2,b]\equiv
[a_1,b^2]\equiv 1 \ (\mod M)$. On the other hand, it follows from
$[a_1,b]\equiv a_2^2e^k \ (\mod M)$ that $[a_1^2,b]\equiv
[a_1,b]^2[a_1,b,a_1]\equiv a_2^4 \ (\mod M)$. It follows that
$a_2^4\in M$ and hence $M=\lg a_1^8, a_2^4\rg$.

Let $L=\lg a_1M,bM\rg$. Since $\exp(L')=2$, Theorem \ref{thm=c=3
exp(G')=p} gives that $c(L)=2$. It follows that $[a_2^2,b]\equiv 1 \
(\mod M)$. On the other hand, $[a_2^2,b]\equiv
[a_2,b]^2[a_2,b,a_2]\equiv a_1^4 \ (\mod M)$. It follows that
$a_1^4\in M$. Hence $M=\mho_1(G)$, a contradiction.

Similarly, $\bar{G}$ is not a group of Type (C10) in Main theorem.

By above argument, $\bar{G}$ is a group of Type (C4) in Main
theorem. That is, $\bar{G}=\bar{K}\times \bar{A}$, where
$\bar{K}=\lg \bar{a}_1,\bar{a}_2,\bar{a}_3\di
 \bar{a}_1^{p^{m_1+1}}=\bar{a}_2^{p^{m_2+1}}=\bar{a}_3^{p^{m_3}}=1,
  [\bar{a}_1,\bar{a}_2]=\bar{a}_1^{p^{m_1}}, [\bar{a}_1,\bar{a}_3]=\bar{a}_2^{p^{m_2}}, [\bar{a}_2,\bar{a}_3]=1\rg$,
$m_1>1$ for $p=2$, $m_1\ge m_2\ge m_3$ and $\bar{A}$ is abelian such
that $\exp(\bar{A})\le p^{m_2}$. Then $G'=\lg
a_1^{p^{m_1}},a_2^{p^{m_2}}\rg$.

Since $G'\le \lg a_2,a_3\rg$, we have $[a_2,a_3]=1$. Since $\lg
\bar{a}_1,\bar{a}_3\rg$ is not metacyclic,  we get $\lg a_1,a_3\rg$
is not metacyclic. By Theorem \ref{thm=d(G)=2--metacyclic},
$[a_1,a_3]^p=1$. Let $[a_1,a_3]=a_2^{p^{m_2}}d$ where $d\in
\mho_1(G')$. Then $a_2^{p^{m_2+1}}d^p=1$. It follows that
$a_2^{p^{m_2+1}}\in\mho_2(G')$. Hence $o(a_1)>p^{m_1+1}$ and
$N=\mho_1(G')=\lg a_1^{p^{m_1+1}},a_2^{p^{m_2+1}}\rg=\lg
a_1^{p^{m_1+1}}\rg$ and $a_2^{p^{m_2+1}}\in\lg a_1^{p^{m_1+2}}\rg$.


Since $G'\not\le \lg a_2,a_3a_1^{p^{m_1}}\rg$, we
have$[a_2,a_3a_1^{p^{m_1}}]=1$ and hence
$[a_1^{p^{m_1}},a_2]=a_1^{p^{2m_1}}=1$. Assume the order of $a_1$ is
$p^{m_1+1+k}$ where $k\ge 1$. Then $m_1>k$.

Let $\bar{A}=\lg \bar{a}_4\rg\times\lg
\bar{a}_5\rg\times\dots\times\lg \bar{a}_f\rg$ and the type of
$\bar{A}$ be $(p^{m_4},p^{m_5},\dots,p^{m_f})$. For $4\le i\le f$
and $1\le j\le f$, since $G'\not\le \lg a_i,a_j\rg$Ҳ������$G'$, we
have $[a_i,a_j]=1$ and hence $a_i\in Z(G)$. Assume that
$a_i^{p^{m_i}}=a_1^{sp^{m_1+1}}$. Then
$(a_ia_1^{-sp^{m_1+1-m_i}})^{p^{m_i}}=1$. Let
$b_i=a_ia_1^{-sp^{m_1+1-m_i}}$, $A=\lg b_4\rg\times\lg
b_5\rg\times\dots\times\lg b_f\rg$ and $K=\lg a_1,a_2,a_3\rg$. Then
$G=K\times A$.

Assume that $[a_1,a_2]=a_1^{p^{m_1}}a_1^{up^{m_1+1}}$. Then
$a_1^{a_2}=a_1^{1+(1+up)p^{m_1}}$. By Lemma \ref{lem=num p odd} and
Lemma \ref{lem=num p 2}, there exists positive integer $w$ such that
$(1+(1+up)p^{m_1})^j= 1+p^{m_1}$. Replacing $a_2$ and $a_3$ with
$a_2^w$ and $a_3^w$ respectively, we have $[a_1,a_2]=a^{p^{m_1}}$.

By Lemma \ref{lem=num p odd} and Lemma \ref{lem=num p 2}, in the
multiplicative group  containing of all invertible elements of $\Bbb
Z/p^{m_1+1+k}\Bbb Z$, the order of $1+p^{m_1}$ is $p^{k+1}$. Since
$a_1^{(1+p^{m_1})^{p^{m_2+1}}}=a_1^{a_2^{p^{m_2+1}}}=a_1$, we have
$k+1\le m_2+1$. Hence $k\le m_2$.

\medskip

Case 1: $k=m_2$.

\medskip

In this case, $m_1>m_2$ and $[a_1,a_2^{p^{m_2}}]\neq 1$. It follows
that $c(\lg a_1,a_3\rg)>2$, Corollary \ref{cor=c=3 exp(G')=p} gives
that $p>2$ and $\lg a_1,a_3\rg\in \mathcal{A}_2$. If $m_3>1$, then
$\lg a_1,a_2^{p^{m_2}}a_3^p\rg$ is neither abelian nor normal in
$G$, a contradiction. Hence we have $m_3=1$. If $A\neq 1$, then,
letting $1\ne e\in A$, $\lg a_1,a_2^{p^{m_2}}e\rg$ is neither
abelian nor normal in $G$, a contradiction. Hence we have $A=1$.
Assume that $a_3^p=a_1^{vp^{m_1+1}}$. Replacing $a_3$ with
$a_3a_1^{-vp^{m_1}}$, we have $a_3^p=1$.

Assume that $[a_1,a_3]=a_2^{p^{m_2}}a_1^{wp^{m_1+1}}$. Then
$a_2^{p^{m_2+1}}a_1^{wp^{m_1+2}}=1$. Since
$$(a_2a_1^{wp^{m_1-m_2+1}})^{p^{m_2+1}}=1,$$ we may assume that
$(a_2a_1^{wp^{m_1-m_2+1}})^{p^{m_2}}=a_2^{p^{m_2}}a_1^{wp^{m_1+1}}a_1^{xp^{m_1+m_2}}$.
Replacing $a_2$ with $a_2a_1^{wp^{m_1-m_2+1}}a_1^{-xp^{m_1}}$, we
have $a_2^{p^{m_2+1}}=1$ and $[a_1,a_3]=a_2^{p^{m_2}}$. Hence $G$ is
a group of Type (G1) in Main theorem.

\medskip

Case 2: $k<m_2$.

\medskip

In this case $[a_1,a_2^{p^{m_2}}]=1$. Since $[a_1,a_3,a_1]=1$, we
have $[a_1^p,a_3]=[a_1,a_3]^p=1$. Since $G'\not\le \lg
a_2,a_3a_1^{p^{m_1-m_3+1}}\rg$, we have
$[a_2,a_3a_1^{p^{m_1-m_3+1}}]=1$. It follows that
$1=[a_1^{p^{m_1-m_3+1}},a_2]=a_1^{p^{2m_1-m_3+1}}$. Hence
$2m_1-m_3+1\ge m_1+1+k$. That is, $m_1-m_3\ge k$. Since $G'\not\le
\lg a_1,a_2^{p^{m_2-m_3+2}}a_3^p\rg$, we have
$[a_1,a_2^{p^{m_2-m_3+2}}a_3^p]=1$. It follows that
$a_1^{a_2^{p^{m_2-m_3+2}}}=a_1^{(1+p^{m_1})^{p^{m_2-m_3+2}}}=a_1$.
By Lemma \ref{lem=num p odd} and Lemma \ref{lem=num p 2}, in the
multiplicative group containing of all invertible elements of $\Bbb
Z/p^{m_1+1+k}\Bbb Z$, the order of $1+p^{m_1}$ is $p^{k+1}$. Hence
we have $m_2-m_3+2\ge k+1$. That is, $k\le m_2-m_3+1$.

Let $b\in A$ and the order of $b$ be $p^e$. Since $G'\not\le \lg
a_1,a_2^{p^{m_2-e+1}}b\rg$, we have $[a_1,a_2^{p^{m_2-e+1}}b]=1$. It
follows that
$a_1^{a_2^{p^{m_2-e+1}}}=a_1^{(1+p^{m_1})^{p^{m_2-e+1}}}=a_1$. By
Lemma \ref{lem=num p odd} and Lemma \ref{lem=num p 2}, in the
multiplicative group containing of all invertible elements of $\Bbb
Z/p^{m_1+1+k}\Bbb Z$, the order of $1+p^{m_1}$ is $p^{k+1}$. Hence
we have $m_2-e+1\ge k+1$. That is, $e\le m_2-k$. By the
arbitrariness of $b$, we have $\exp(A)\le p^{m_2-k}$.

Assume that $a_3^p=a_1^{vp^{m_1+1}}$. Replacing $a_3$ with
$a_3a_1^{-vp^{m_1}}$, we have $a_3^p=1$.

Assume that $[a_1,a_3]=a_2^{p^{m_2}}a_1^{wp^{m_1+1}}$. Then
$a_2^{p^{m_2+1}}a_1^{wp^{m_1+2}}=1$. Replacing $a_2$ with
$a_2a_1^{wp^{m_1-m_2+1}}$, we have $a_2^{p^{m_2+1}}=1$ and
$[a_1,a_3]=a_2^{p^{m_2}}$. Hence $G$ is a group of Type (G2) in Main
theorem.
 \qed


\section{The proof of Main theorem}
\begin{thm}\label{lizi=metacyclic} Groups of Type $(E1)$--$(E4)$ in Main theorem are all metahamiltonian.
\end{thm}
\demo  For a group of Type (E1), let $H\le G$ such that $d(H)=2$.
Then we may assume that $H=\lg b^{i_1}a^{j_1}, b^{i_2}a^{j_2}\rg$,
and without loss of generality, $b^{i_2}\in\lg b^{i_1}\rg$. Let
$b^{i_2}=(b^{i_1})^k$. Then
$(b^{i_1}a^{j_1})^{-k}b^{i_2}a^{j_2}\in\lg a\rg$. Hence we may
assume that $H=\lg b^{i_1}a^{j_1}, a^l\rg$. Moreover, we may assume
that $H=\lg b^{p^i}a^j, a^{p^k}\rg$ where $i,j,k$ are non-negative
integers. If $k\le r$, then $G'\le H$ and hence $H\unlhd G$. If
$k\ge r+1$, then $r+k\ge r+s+u$. It follows that
$[a^{p^k},b]=a^{-p^k}(a^{p^k})^b=a^{p^{r+k}}=1$. Hence $H$ is
abelian. By the arbitrariness of $H$, $G$ is metahamiltonian. For
other types, by Lemma \ref{A_2}, $G\in\mathcal{A}_2$ and hence $G$
is metahamiltonian.
 \qed


\begin{thm}\label{lizi=G'=C_p^n} Groups of Type $(F1)$--$(F5)$ in Main theorem are all metahamiltonian such that $|G'|\ge
p^2$ and $G'$ is cyclic. Moreover, they are mutually non-isomorphic.
\end{thm}
\demo Firstly we prove that $G$ is metahamiltonian and $K\le G$ such
that $K'=G'$ and has minimal order.

For groups of Type (F1), let $H=\lg b^{i_1}a^{j_1}x,
b^{i_2}a^{j_2}y\rg$, where $x,y\in A$. Without loss of generality,
we may assume that $b^{i_2}\in\lg b^{i_1}\rg$. Let
$b^{i_2}=(b^{i_1})^k$. Then
$(b^{i_1}a^{j_1}x)^{-k}b^{i_2}a^{j_2}y\in\lg a\rg\times A$. Hence we
may assume that $H=\lg  b^{i_1}a^{j_1}x, a^ly\rg$, where $x,y\in A$.
Moreover, we may assume that $H=\lg b^{p^i}a^jx, a^{p^k}y\rg$, where
$i,j,k$ are non-negative integers and $x,y\in A$. By calculation,
$(a^{p^k}y)^{p^{(r+1)-(s+u)}}=a^{p^{(r+1)-(s+u)+k}}$. If $k\le
s+u-1$, then $G'\le H$ and hence $H\unlhd G$. If $k\ge s+u$, then
$[a^{p^k},b]=a^{-p^k}(a^{p^k})^b=a^{p^{r+k}}=1$. It follows that
$[a^{p^k}y,b^{p^i}a^jx]=[a^{p^k},b^{p^i}]=1$. Hence $H$ is abelian.
By the arbitrariness of $H$, $G$ is metahamiltonian. If $H'=G'$ then
$i=k=0$. In this case, we may assume that $H=\lg bx,ay\rg$, where
$x,y\in A$. Since $H\cong K$, we get $K\le G$ such that $K'=G'$ and
has minimal order.

For groups of Type (F2), let $H=\lg b^{i_1}a^{j_1}x,
b^{i_2}a^{j_2}y\rg$, where $x,y\in A$. Without loss of generality,
we may assume that $b^{i_2}\in\lg b^{i_1}\rg$. Let
$b^{i_2}=(b^{i_1})^k$. Then
$(b^{i_1}a^{j_1}x)^{-k}b^{i_2}a^{j_2}y\in\lg a\rg \times A$. Hence
we may assume that $H=\lg  b^{i_1}a^{j_1}x, a^ly\rg$, where $x,y\in
A$. Moreover, we may assume that $H=\lg b^{p^i}a^jx, a^{p^k}y\rg$,
where $i,j,k$ are non-negative integers and $x,y\in A$. By
calculation, $(a^{p^k}y)^{p^{t+(r+1)-u}}=a^{p^{t+(r+1)-u+k}}$. If
$k\le u-1$, then $G'\le H$ and hence $H\unlhd G$. If $k\ge u$, then
$[a^{p^k},b]=a^{-p^k}(a^{p^k})^b=a^{p^{r+t+k}}=1$. It follows that
$[a^{p^k}y,b^{p^i}a^jx]=[a^{p^k},b^{p^i}]=1$. Hence $H$ is abelian.
By the arbitrariness of $H$, $G$ is metahamiltonian. If $H'=G'$ then
$i=k=0$. In this case, we may assume that $H=\lg bx,ay\rg$, where
$x,y\in A$. Since $H\cong K$, we get $K\le G$ such that $K'=G'$ and
has minimal order.

For groups of Type (F3), let $H=\lg b^{i_1}a^{j_1}x,
b^{i_2}a^{j_2}y\rg$, where $x,y\in A$. Without loss of generality,
we may assume that $b^{i_2}\in\lg b^{i_1}\rg$. Let
$b^{i_2}=(b^{i_1})^k$. Then
$(b^{i_1}a^{j_1}x)^{-k}b^{i_2}a^{j_2}y\in\lg a\rg \times A$. Hence
we may assume that $H=\lg  b^{i_1}a^{j_1}x, a^ly\rg$, where $x,y\in
A$. Moreover, we may assume that $H=\lg b^{p^i}a^jx, a^{p^k}y\rg$,
where $i,j,k$ are non-negative integers and $x,y\in A$. By
calculation, $(a^{p^k}y)^{p^{(r+1)-s}}=a^{p^{(r+1)-s+k}}$. If $k\le
s-1$, then $G'\le H$ and hence $H\unlhd G$. If $k\ge s$, then
$[a^{p^k},b]=a^{-p^k}(a^{p^k})^b=a^{p^{r+k}}=1$. It follows that
$[a^{p^k}y,b^{p^i}a^jx]=[a^{p^k},b^{p^i}]=1$. Hence $H$ is abelian.
By the arbitrariness of $H$, $G$ is metahamiltonian. If $H'=G'$ then
$i=k=0$. In this case, we may assume that $H=\lg bx,ay\rg$, where
$x,y\in A$. Since $H\cong K$, we get $K\le G$ such that $K'=G'$ and
has minimal order.

For groups of Type (F4), let $H=\lg b^{i_1}a^{j_1}x,
b^{i_2}a^{j_2}y\rg$, where $x,y\in A$. Without loss of generality,
we may assume that $b^{i_2}\in\lg b^{i_1}\rg$. Let
$b^{i_2}=(b^{i_1})^k$. Then
$(b^{i_1}a^{j_1}x)^{-k}b^{i_2}a^{j_2}y\in\lg a\rg \times A$. Hence
we may assume that $H=\lg  b^{i_1}a^{j_1}x, a^ly\rg$, where $x,y\in
A$. Moreover, we may assume that $H=\lg b^{p^i}a^jx, a^{p^k}y\rg$,
where $i,j,k$ are non-negative integers and $x,y\in A$. By
calculation, $(a^{p^k}y)^{p^{(r+1)-(s+u)}}=a^{p^{(r+1)-(s+u)+k}}$.
If $k\le s+u-1$, then $G'\le H$ and hence $H\unlhd G$. If $k\ge
s+u$, then $[a^{p^k},b]=a^{-p^k}(a^{p^k})^b=a^{p^{r+k}}=1$. It
follows that $[a^{p^k}y,b^{p^i}a^jx]=[a^{p^k},b^{p^i}]=1$. Hence $H$
is abelian. By the arbitrariness of $H$, $G$ is metahamiltonian. If
$H'=G'$ then $i=k=0$. In this case, we may assume that $H=\lg
bx,ay\rg$, where $x,y\in A$. Since $H\cong K$, we get $K\le G$ such
that $K'=G'$ and has minimal order.

For groups of Type (F5), let $H=\lg \rho_1,\rho_1\rg$, where
$\rho_1=b^{i_1}b_1^{u_1}\dots b_f^{u_f}a^{j_1}x$,
$\rho_2=b^{i_2}b_1^{v_1}\dots b_f^{v_f}a^{j_2}y$ and $x,y\in A$.
Without loss of generality, we may assume that $b^{i_2}\in\lg
b^{i_1}\rg$. Let $b^{i_2}=(b^{i_1})^k$. Then $\rho_1^{-k}\rho_2\in
(\lg a \rg\rtimes B)\times A$. Hence we may assume that
$\rho_1=b^{p^i}b_1^{u_1}\dots b_f^{u_f}a^{jp^\alpha}x, \rho_2
=b_1^{v_1}\dots b_f^{v_f}a^{kp^\beta}y$, where $(jk,p)=1$ and
$x,y\in A$. Since $t_1\ge u-1$ and $r+t>t_1+r_1$, we have
$r_1<t+(r+1)-u$. By calculation,
$\rho_1^{p^{(r+1)+t_1-u}}=a^{jp^{(r+1)+t_1-u+\alpha}}$ and
$\rho_2^{p^{t+(r+1)-u}}=a^{kp^{t+(r+1)-u+\beta}}$. If $\alpha\le
u+t-t_1-1$ or $\beta\le u-1$, then $G'\le H$ and hence $H\unlhd G$.
If $\alpha\ge u+t-t_1$ and $\beta\ge u$, then $r+t+\beta\ge r+s+u$
and $r+t_1+\alpha\ge r+t+u$. Hence we have
$[a^{p^\alpha},b_w]=a^{-p^\alpha}(a^{p^\alpha})^{b_w}=a^{p^{r+t_w+\alpha}}=1$,
$[a^{p^\beta},b]=a^{-p^\beta}(a^{p^\beta})^b=a^{p^{r+t+\beta}}=1$
and
$[a^{p^\beta},b_w]=a^{-p^\beta}(a^{p^\beta})^{b_w}=a^{p^{r+t_w+\beta}}=1$
for all $1\le w\le f$. It follows that $[\rho_1,\rho_2]=1$ and $H$
is abelian. By the arbitrariness of $H$, $G$ is metahamiltonian. If
$H'=G'$ then $i=k=0$. In this case, $H=\lg bb_1^{u_1}\dots
b_f^{u_f}a^{jp^\alpha}x,b_1^{v_1}\dots b_f^{v_f}ay\rg$ where $x,y\in
A$. It is easy to see that $K\le G$ such that $K'=G'$ and has
minimal order.

Finally we prove that groups in the theorem are mutually
non-isomorphic. Since $K$ is a direct factor for Type (F1)--(F4),
and not a direct factor for Type (F5), a group of Type (F5) is not
isomorphic to that of other types.

Let $t=0$ for the group of Type (F1), $s=0$ for the group of Type
(F2) and $u=0$ for the group of Type (F3). It is easy to see that:

(i) $|K|=p^{2r+2s+t+u}$;

(ii) $\exp(G)=p^{r+s+t+u}$;

(iii) $\exp(G/G')=p^{r+s+t}$;

(iv) $|G'|=p^{s+u}$.

Hence $r,s,t,u$ are invariants of $G$. It follows that distinct
parameters $r,s,t,u$ give non-isomorphic groups. In particular,
groups of distinct types are not isomorphic. Since $G/G'\cong
K/K'\times A$, we get that distinct $A$ give non-isomorphic groups.

Similar to above argument, $r,t,u$ are invariants of groups of Type
(F5). Let $\tilde{G}=G/\mho_{\delta-t}(G')$. If $t<\delta\le t_1$,
then $K/\mho_{\delta-t}(G')$ is a direct factor of $\tilde{G}$. If
$\delta>t_1$, then there does not exist direct factor $\tilde{K}$ of
$\tilde{G}$ such that $\tilde{K}'=\tilde{G}'$ and $\tilde{K}$ is
metacyclic. It follows that $t_1$ is an invariant of $G$. Moreover,
if $\delta=t_1+1$, then $\tilde{T}=(K\rtimes\lg
b_1\rg)/\mho_{\delta-t}(G')$ is the minimal director factor whose
derived group coincide with that of $\tilde{G}$. Since
$|\tilde{T}|=p^{2r+t+u+r_1}$, $r_1$ is also an invariant of $G$.
Similarly, if $t_i<\delta\le t_{i+1}$, then
$\tilde{T}_i=(K\rtimes(\lg b_1\rg\times\lg b_2\rg\dots\lg
b_i\rg))/\mho_{\delta-t}(G')$ is a direct factor of $\tilde{G}$
whose derived group coincide with that of $\tilde{G}$ and
$d(\tilde{T})=i+2$. If $\delta>t_{i+1}$, then there does not exist
direct factor $\tilde{K}$ of $\tilde{G}$ such that
$\tilde{K}'=\tilde{G}'$ and $d(\tilde{K})=i+2$. Moreover, if
$\delta=t_{i+1}+1$, then $\tilde{T}_{i+1}$ is the minimal director
factor whose derived group coincide with that of $\tilde{G}$. Since
$|\tilde{T}_{i+1}|=p^{2r+t+u+r_1+r_2+\dots+r_{i+1}}$, by induction,
$t_i$ and $r_{i+1}$ are invariants of $G$. Hence distinct $B$ give
non-isomorphic groups. Since $G/G'\cong K/G'\times B\times A$,
distinct $A$ give non-isomorphic groups. \qed

\medskip

\noindent {\bf Proof of Main theorem:} Firstly, we can prove that
groups in theorem are all metahamiltonian and they are mutually
non-isomorphic. The proof is similar to that of Theorem
\ref{lizi=G'=C_p^n}.

Suppose that $G$ is metahamiltonian. Next we prove that $G$ is a
group in theorem.

Case 1. $G'$ is elementary abelian.

By Theorem \ref{thm=metahamilton p-gp G, c(G) is at most 3},
$c(G)\le 3$. If $c(G)=3$, then, by Theorem \ref{thm=c=3 exp(G')=p},
$G\in \mathcal{A}_2$. Checking groups listed in Lemma \ref{A_2}, we
get groups (B1)--(B8). In the following, we may assume that
$c(G)=2$.  Let $N$ be a minimal non-abelian subgroup of $G$. By
Theorem \ref{G'<N}, $G'\le N$. Since $G'\le Z(G)$, $G'\le
\Omega_1(Z(N))=\Omega_1(\Phi(N))$. It follows from Theorem
\ref{thm=Redei} that $G'\le C_p^3$. If $G'\cong C_p$, then $G$ is of
Type (A) in theorem. If $G'\cong C_p^2$, then, by Theorem
\ref{thm=G'=p^2}, $G$ is a group of Type (C1)--(C10) in theorem. If
$G'\cong C_p^3$, then, by Theorem \ref{thm=G'=p^3}, $G$ is a group
of Type (D1)--(D5) in theorem.

Case 2. $G'$ is not elementary abelian.

If $G$ is metacyclic, then, by Theorem \ref{metacyclic
metahamilton}, $G$ is a group of Type (E1)--(E4) in theorem. In the
following, we may assume that $G$ is not metacyclic. If $G'$ is
cyclic, then, by Theorem \ref{thm=G'=C_p^n}, $G$ is a group of Type
(F1)--(F5) in theorem. If $G'$ is not cyclic, then, by Theorem
\ref{thm=G'=C_p^n*c_p}, $G$ is a group of Type (G1)--(G2) in
theorem.\qed




\begin{thebibliography}{99}

\bibitem{ADZ}
L.J. An, J.F. Ding and Q.H. Zhang, Finite self dual groups, {\it J.
Algebra}, {\bf341}(2011), 35--44.


\bibitem{ALQZ}
L.J. An, L.L. Li, H.P. Qu and Q.H. Zhang, Finite p-groups with a
minimal non-abelian subgroup of index $p$ (II), {\it in
preparation}.

\bibitem{AP}
L.J. An and J. Peng, Finite $p$-groups in which any two
noncommutative elements generate an inner abelian group of order
$p^4$, {\it Algebra Colloq.}, to appear.

\bibitem{Baer}
R. Baer, Situation der Untergruppen und struktur der Gruppen, {\it
S. B. Heidelberg Akad. Mat. Nat.}, {\bf 2}(1933), 12--17.

\bibitem{Yak0}
Y. Berkovich, Finite $p$-groups with few minimal nonabelian
subgroups, J. Algebra, 297 (2006), 62--100.

\bibitem{Ber1}
Y. Berkovich, Groups of Prime Power Order, Vol.1 {\it Walter de
Gruyter, Berlin}, 2008.


\bibitem{BJ}
Y. Berkovich and Z. Janko, Structure of finite $p$-groups with given
subgroups, {\it Contemp. Math. $402$}, Amer. Math. Soc., Providence,
RI. (2006), 13--93.



\bibitem{Ber2}
Y. Berkovich and Z. Janko, Groups of Prime Power Order, Vol.2 {\it
Walter de Gruyter, Berlin}, 2008.


\bibitem{Bla}
N. Blackburn, On prime power groups with two generators, {\it Proc.
Cambrige Phil. Soc.}, {\bf 54}(1957), 327--337.

\bibitem{Ded} R. Dedekind, ${\rm \ddot{U}}$ber Gruppen, deren
samtliche Teiler Normalteiler sind, {\it Math. Ann.}, {\bf48}(1897),
548--561.

\bibitem{Dra}
S.V. Draganyuk, On the structure of finite primary groups all
2-maximal subgroups of which are abelian (Russian), in Complex
analysis, Algebra and topology, Akad. Nauk Ukrain. SSR, Inst. Mat.,
Kiev.(1990), 42--51.

\bibitem{Kaz}
L.S. Kazarin, On certain classes of finite groups, {\it Dokl. Akad.
Nauk SSSR (Russian)}, {\bf 197}(1971), 773--776.

\bibitem{Hup}
B. Huppert, {\it Endliche Gruppen I,} Springer-Verlag, 1967.

\bibitem{Hup2}
B. Huppert and N. Blackburn, {\it Finite Group II,} Springer-Verlag,
1982.

\bibitem{king}
B.W. King, Presentations of metacyclic groups, {\it Bull. Austral.
Math. Soc.} {\bf 8}(1973), 103-131.


 \bibitem{Nag1}
V.T. Nagrebeckii, Invariant coverings of subgroups, {\it Ural Gos.
Univ. Mat. Zap.}, {\bf5}(1966), 91--100.

\bibitem{Nag2}
 V.T. Nagrebeckii, Finite
non-nilpotent groups, any non-abelian subgroup of which is normal,
{\it Ural Gos. Univ. Mat. Zap.}, {\bf6}(1967), 80--88.

\bibitem{Nag3}
V.T. Nagrebeckii, Finite groups in which any non-nilpotent subgroups
is invariant, {\it Ural Gos. Univ. Mat. Zap.}, {\bf7} (1968),
45--49.

\bibitem{NX}
M.F. Newman and M.Y. Xu, Metacyclic groups of prime-power order
(Research announcement), {\it Adv. in Math. $($Beijing$)$} {\bf
17}(1988), 106-107.

\bibitem{Pas} D.S. Passman, Nonnormal subgroups of $p$-groups, {\it J.
 Algebra}, {\bf 15}(1970), 352--370.

\bibitem{QXA}
H.P. Qu, M.Y. Xu and L.J. An, Finite p-groups with a minimal
non-abelian subgroup of index $p$ (III), {\it in preparation}.

\bibitem{R}
L.R$\acute{e}dei$,  Das schiefe Product in der Gruppentheorie, {\it
Comment.Math.Helvet.}, {\bf 20}(1947), 225--267.

\bibitem{RS1} G.M. Romalis and N.F. Sesekin,
Metahamiltonian groups, {\it Ural. Gos. Univ. Mat. Zap.},
{\bf5}(1966), 101--106.


\bibitem{RS2} G.M. Romalis and N.F. Sesekin,
Metahamiltonian groups II, {\it Ural. Gos. Univ. Mat. Zap.},
{\bf6}(1968), 52--58.

\bibitem{RS3} G.M. Romalis and N.F. Sesekin, Metahamiltonian
groups III, {\it Ural. Gos. Univ. Mat. Zap.}, {\bf7}(1969--1970),
195--199.

\bibitem{She}
V.A. Sheriev, A description of the class of finite p-groups whose
2-maximal subgroups are all abelian II, in Primary groups, {\it
Proc. Sem. Algebraic Systems}, {\bf 2}(1970), 54--76.


\bibitem{ZGQX} Q.H. Zhang, X.Q. Guo, H.P. Qu and
M.Y. Xu, Finite groups which have many normal subgroups, {\it J.
Korean Math. Soc.}, {\bf46}(2009), 1165-1178.

\bibitem{Alj}
M.Y. Xu, L.J. An and Q.H. Zhang, Finite $p$-groups all of whose
non-abelian proper subgroups are generated by two elements, {\it J.
Algebra}, 319(2008), 3603--3620.


\bibitem{XZ1}
M.Y. Xu and Q.H. Zhang, A classification of metacyclic $2$-groups,
{\it Algebra Colloq.}, 13:1 (2006), 25--34.

\bibitem{ZSAX}
Q.H. Zhang, X.J. Sun, L.J. An and M.Y. Xu, Finite $p$-groups all of
whose subgroups of index $p^2$ are abelian, {\it Algebra
Colloquium}, {\bf 15:1}(2008), 167-180.

\end{thebibliography}


\end{document}

1310.5509.extracted_bib
\begin{thebibliography}{99}

\bibitem{ADZ}
L.J. An, J.F. Ding and Q.H. Zhang, Finite self dual groups, {\it J.
Algebra}, {\bf341}(2011), 35--44.


\bibitem{ALQZ}
L.J. An, L.L. Li, H.P. Qu and Q.H. Zhang, Finite p-groups with a
minimal non-abelian subgroup of index $p$ (II), {\it in
preparation}.

\bibitem{AP}
L.J. An and J. Peng, Finite $p$-groups in which any two
noncommutative elements generate an inner abelian group of order
$p^4$, {\it Algebra Colloq.}, to appear.

\bibitem{Baer}
R. Baer, Situation der Untergruppen und struktur der Gruppen, {\it
S. B. Heidelberg Akad. Mat. Nat.}, {\bf 2}(1933), 12--17.

\bibitem{Yak0}
Y. Berkovich, Finite $p$-groups with few minimal nonabelian
subgroups, J. Algebra, 297 (2006), 62--100.

\bibitem{Ber1}
Y. Berkovich, Groups of Prime Power Order, Vol.1 {\it Walter de
Gruyter, Berlin}, 2008.


\bibitem{BJ}
Y. Berkovich and Z. Janko, Structure of finite $p$-groups with given
subgroups, {\it Contemp. Math. $402$}, Amer. Math. Soc., Providence,
RI. (2006), 13--93.



\bibitem{Ber2}
Y. Berkovich and Z. Janko, Groups of Prime Power Order, Vol.2 {\it
Walter de Gruyter, Berlin}, 2008.


\bibitem{Bla}
N. Blackburn, On prime power groups with two generators, {\it Proc.
Cambrige Phil. Soc.}, {\bf 54}(1957), 327--337.

\bibitem{Ded} R. Dedekind, ${\rm \ddot{U}}$ber Gruppen, deren
samtliche Teiler Normalteiler sind, {\it Math. Ann.}, {\bf48}(1897),
548--561.

\bibitem{Dra}
S.V. Draganyuk, On the structure of finite primary groups all
2-maximal subgroups of which are abelian (Russian), in Complex
analysis, Algebra and topology, Akad. Nauk Ukrain. SSR, Inst. Mat.,
Kiev.(1990), 42--51.

\bibitem{Kaz}
L.S. Kazarin, On certain classes of finite groups, {\it Dokl. Akad.
Nauk SSSR (Russian)}, {\bf 197}(1971), 773--776.

\bibitem{Hup}
B. Huppert, {\it Endliche Gruppen I,} Springer-Verlag, 1967.

\bibitem{Hup2}
B. Huppert and N. Blackburn, {\it Finite Group II,} Springer-Verlag,
1982.

\bibitem{king}
B.W. King, Presentations of metacyclic groups, {\it Bull. Austral.
Math. Soc.} {\bf 8}(1973), 103-131.


 \bibitem{Nag1}
V.T. Nagrebeckii, Invariant coverings of subgroups, {\it Ural Gos.
Univ. Mat. Zap.}, {\bf5}(1966), 91--100.

\bibitem{Nag2}
 V.T. Nagrebeckii, Finite
non-nilpotent groups, any non-abelian subgroup of which is normal,
{\it Ural Gos. Univ. Mat. Zap.}, {\bf6}(1967), 80--88.

\bibitem{Nag3}
V.T. Nagrebeckii, Finite groups in which any non-nilpotent subgroups
is invariant, {\it Ural Gos. Univ. Mat. Zap.}, {\bf7} (1968),
45--49.

\bibitem{NX}
M.F. Newman and M.Y. Xu, Metacyclic groups of prime-power order
(Research announcement), {\it Adv. in Math. $($Beijing$)$} {\bf
17}(1988), 106-107.

\bibitem{Pas} D.S. Passman, Nonnormal subgroups of $p$-groups, {\it J.
 Algebra}, {\bf 15}(1970), 352--370.

\bibitem{QXA}
H.P. Qu, M.Y. Xu and L.J. An, Finite p-groups with a minimal
non-abelian subgroup of index $p$ (III), {\it in preparation}.

\bibitem{R}
L.R$\acute{e}dei$,  Das schiefe Product in der Gruppentheorie, {\it
Comment.Math.Helvet.}, {\bf 20}(1947), 225--267.

\bibitem{RS1} G.M. Romalis and N.F. Sesekin,
Metahamiltonian groups, {\it Ural. Gos. Univ. Mat. Zap.},
{\bf5}(1966), 101--106.


\bibitem{RS2} G.M. Romalis and N.F. Sesekin,
Metahamiltonian groups II, {\it Ural. Gos. Univ. Mat. Zap.},
{\bf6}(1968), 52--58.

\bibitem{RS3} G.M. Romalis and N.F. Sesekin, Metahamiltonian
groups III, {\it Ural. Gos. Univ. Mat. Zap.}, {\bf7}(1969--1970),
195--199.

\bibitem{She}
V.A. Sheriev, A description of the class of finite p-groups whose
2-maximal subgroups are all abelian II, in Primary groups, {\it
Proc. Sem. Algebraic Systems}, {\bf 2}(1970), 54--76.


\bibitem{ZGQX} Q.H. Zhang, X.Q. Guo, H.P. Qu and
M.Y. Xu, Finite groups which have many normal subgroups, {\it J.
Korean Math. Soc.}, {\bf46}(2009), 1165-1178.

\bibitem{Alj}
M.Y. Xu, L.J. An and Q.H. Zhang, Finite $p$-groups all of whose
non-abelian proper subgroups are generated by two elements, {\it J.
Algebra}, 319(2008), 3603--3620.


\bibitem{XZ1}
M.Y. Xu and Q.H. Zhang, A classification of metacyclic $2$-groups,
{\it Algebra Colloq.}, 13:1 (2006), 25--34.

\bibitem{ZSAX}
Q.H. Zhang, X.J. Sun, L.J. An and M.Y. Xu, Finite $p$-groups all of
whose subgroups of index $p^2$ are abelian, {\it Algebra
Colloquium}, {\bf 15:1}(2008), 167-180.

\end{thebibliography}