%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\newcommand\mb{\boldmath}
\newcommand\mn{\rm}
\newcommand\mc{\cal}
\def\disp{\displaystyle}
\def\ra{\rightarrow}
\def\vecn#1{(#1_1,\ldots,#1_n)}
\def\permn#1{#1_1\cdots #1_n}
\def\cl#1{{\mc #1}}
\newcommand\ch{\choose} %Binomial coefficients
\newcommand\clS{{\mc S}}        %Symmetric group
\newcommand\sn{\mbox{${\cal S}_n$}}
%%%%%%%%%%%%%% Eulerian stats %%%%%%%%%%%%%%%%%%%%%%
\newcommand\des{\mathop{\mn des}\nolimits}
\newcommand\exc{\mathop{\mn exc}\nolimits}
%%%%%%%%%%%%%% Mahonian stats %%%%%%%%%%%%%%%%%%%%%%
\newcommand\inv{\mathop{\mbox{\sc inv}}\nolimits}
\newcommand\expinv{\mathop{\mbox{$\mn\scriptscriptstyle INV$}}}
\newcommand\env{\mathop{\mbox{\sc env}}\nolimits}
\newcommand\maj{\mathop{\mbox{\sc maj}}\nolimits}
\newcommand\expmaj{\mathop{\mbox{$\mn\scriptscriptstyle MAJ$}}}
\newcommand\imaj{\mathop{\mbox{\sc imaj}}\nolimits}
\newcommand\mad{\mathop{\mbox{\sc mad}}\nolimits}
\newcommand\expmad{\mathop{\mbox{$\mn\scriptscriptstyle MAD$}}}
\newcommand\mak{\mathop{\mbox{\sc mak}}\nolimits}
\newcommand\madl{\mathop{\mbox{\sc madl}}\nolimits}
\newcommand\makl{\mathop{\mbox{\sc makl}}\nolimits}
\newcommand\den{\mathop{\mbox{\sc den}}\nolimits}
\newcommand\mah{\mathop{\mbox{\sc mah}}\nolimits}
\newcommand\sist{\mathop{\mbox{\sc sist}}\nolimits}
\newcommand\lag{\mathop{\mbox{\sc lag}}\nolimits}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Partial stats %%%%%%%%%%%%%%%%%%%%%%
\newcommand\res{\mathop{\mn Res}\nolimits}
\newcommand\les{\mathop{\mn Les}\nolimits}
\newcommand\dtop{\mathop{\mn Dtop}\nolimits}
\newcommand\etop{\mathop{\mn Etop}\nolimits}
\newcommand\dbot{\mathop{\mn Dbot}\nolimits}
\newcommand\ebot{\mathop{\mn Ebot}\nolimits}
\newcommand\ddiff{\mathop{\mn Ddif}\nolimits}
\newcommand\ddif{\mathop{\mn Ddif}\nolimits}
\newcommand\ediff{\mathop{\mn Edif}\nolimits}
\newcommand\edif{\mathop{\mn Edif}\nolimits}
\newcommand\imv{\mathop{\mn Imv}\nolimits}
\newcommand\ine{\mathop{\mn Ine}\nolimits}

%%%%%%%%%%%%% Miscellaneous%%%%%%%%%%%%%%%%
\def\EXC#1{#1_{\mbox{$\mn\scriptscriptstyle E$}}}
\def\NEX#1{#1_{\mbox{$\mn\scriptscriptstyle N$}}} \def\inve#1{\inv
#1_{\mbox{\sc e}}} \def\imve#1{\imv #1_{\mbox{\sc e}}}
\def\invn#1{\inv #1_{\mbox{\sc n}}}
\def\phiw{\mbox{$\Phi_{\mbox{$\mn\scriptscriptstyle W$}}$}}
\def\phik{\mbox{$\Phi_k$}}
\def\phikw{\mbox{$\Phi_{k,\mbox{$\mn\scriptscriptstyle W$}}$}}
\newcommand\op{\mbox{\sc o}}
\newcommand\clo{\mbox{\sc c}}

\newcommand\imversion{\mbox{i\kern -.15mm{\em m}\kern .15mm version}}
\newcommand\imversions{\mbox{i\kern -.15mm{\em m}\kern .15mm versions}}
\newcommand\iimversion{\mbox{i\kern .23mm{\em m}\kern -.23mm version}}
\newcommand\iimversions{\mbox{i\kern .23mm{\em m}\kern -.23mm versions}}

\newcommand{\mpg}{\marginpar}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\w{\mbox{$w$}}
\newcommand\ww{\mbox{$w'$}}
\newcommand\p{\mbox{$\pi$}}
\newcommand\pp{\mbox{$\pi'$}}
\newcommand\ta{\mbox{$\tau$}}
\newcommand\wb{\mbox{$\overline{w}$}}
\newcommand\wt{\mbox{$\widetilde{w}$}}
\newcommand\piti{\mbox{$\widetilde{\pi}$}}
\newcommand\pst{\mbox{$\widetilde{\pi*}$}}
\newcommand\ppt{\mbox{$\widetilde{\pi'}$}}
\newcommand\ppst{\mbox{$\widetilde{\pi'*}$}}
\newcommand\wwt{\mbox{$\widetilde{w'}$}}
\newcommand\ol{\overline}
\newcommand\e{\mbox{$\epsilon$}}
\newcommand\ep{\mbox{$\epsilon(\pi)$}}
\newcommand\eep{\mbox{$\epsilon^2(\pi)$}}
\newcommand\cb{\mbox{\bf c}}
%%%% Structure of Thms. etc.  %%%%%%%%%%%%%%
\newtheorem{thm}{Theorem}
\newtheorem{con}{Conjecture}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{defn}{Definition}
\newtheorem{defns}[defn]{Definitions}
\newtheorem{eg}{Example}
\newtheorem{egs}[eg]{Examples}
\newtheorem{remark}{Remark}
\newtheorem{fact}[remark]{Fact}
\newtheorem{blank}[remark]{$\!\!$}
\newtheorem{porism}[thm]{Porism}
\newtheorem{conj}{Conjecture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\pf}{{\bf Proof: \/}}
\def\qed{\nobreak\quad\raise -2pt\hbox{\vrule\vbox to 10pt{\hrule width 6pt
\vfill\hrule}\vrule}\par\vspace{2ex}}
\def\qel{\nobreak\quad\raise -2pt\hbox{\vrule\vbox to 10pt{\hrule width 6pt
\vfill\hrule}\vrule}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\oddsidemargin 9mm
\evensidemargin -1mm

\begin{document}
\title{The $k$-Extensions of some new Mahonian statistics}
\author{Robert J. Clarke%
\thanks{This work was carried out while the author was Visiting
Professor at the Universit\'e Louis-Pasteur in Strasbourg during summer and
autumn of 1995.}
\\Pure Mathematics Department
\\University of Adelaide
\\Adelaide, South Australia 5005
\and
Einar Steingr{\'\i}msson%
\thanks{Partially supported by a grant from
      The Icelandic Council of Science and partially supported by the EU
      Network in Algebraic Combinatorics while visiting Universit\'e
      Louis-Pasteur in Strasbourg.}\\
Matematiska institutionen \\
CTH \& GU\\
412 96 G\"oteborg, Sweden
\and
Jiang Zeng\thanks{Partially supported by the EU
Network in Algebraic Combinatorics.}
\\ D\'epartement de math\'ematique
 \\Universit\'e Louis-Pasteur
\\ 67084 Strasbourg Cedex, France}
\maketitle
\thispagestyle{empty}
\newpage
\begin{abstract}
\noindent In previous work by the authors, new Mahonian statistics $\env$,
$\mad$
and $\mak$ were defined on words and it was shown that $\env$ is equal to the
classical statistic $\inv$ and that the triple statistics $(\des,\mak,\mad)$ and
$(\exc,\den,\env)$ are equidistributed over any rearrangement class of words.
Here, $\exc$ and $\des$ are the classical Eulerian statistics, while $\den$ is
Denert's statistic. In addition, a bijection between the symmetric group
and sets
of weighted Motzkin paths was used to give a continued fraction expression for
the generating function of $(\exc,\inv)$ or $(\des,\mad)$ on the symmetric
group.
These results are extended to the case in which the letters of the alphabet used
are divided into two classes, large and small, with corresponding changes to the
definitions of the above statistics.
\end{abstract}

\section{Introduction}
Let $\cb=(c_1,c_2,\ldots,c_m)$ be a sequence of non-negative integers
with $n=c_1+c_2+\cdots+c_m$.  Denote by $R(\cb)$ the set of all
rearrangements of the (non-decreasing) word $1^{c_1}2^{c_2}\ldots
m^{c_m}$.
In \cite{CSZ}, some new Mahonian statistics $\mad$, $\mak$ and $\env$
on $R(\cb)$ were introduced and the following results were proved.
\begin{thm}
For all $w\in R(\cb)$, we have $\env w=\inv w$.
\end{thm}

\begin{thm}
The triples $(\des,\mad,\mak)$ and $(\exc,\inv,\den)$ are
equidistributed on $R(\cb)$.
\end{thm}

In fact, a bijection $\phiw$ was constructed on $R(\cb)$ such that for all $w\in
R(\cb)$,
$$
(\des,\mad,\mak)\ w=(\exc,\inv,\den)\ \phiw(w).
$$

In \cite{CF1,CF2,F,H}, the statistics $\des$, $\exc$, $\maj$, $\den$
and $\inv$ were extended to the case in which the letters in
$[m]:=\{1, 2, \ldots, m\}$ are divided into two classes. Namely, let
$k$ be a non-negative integer such that $k\le m$ and put $\ell=m-k$.
The letters 1, 2, \dots, $\ell$ are called {\em small\/} and the
letters $\ell+1$, \dots, $m$ are called {\em large\/}.  In counting
descents and excedances, one counts strict inequalities between small
letters, but equalities and inequalities between large letters---see
below for the details. Then $k$-extended statistics $\des_k$,
$\exc_k$, $\maj_k$, $\den_k$ and $\inv_k$ are defined, which reduce to
their more familiar Eulerian and Mahonian counterparts in the case
$k=0$. Further, the pairs $(\des_k,\maj_k)$ and $(\exc_k,\den_k)$ are
equidistributed on $R(\cb)$.  It is the purpose of this paper to
$k$-extend the results of \cite{CSZ}. We will define statistics
$\mad_k$, $\mak_k$ and $\env_k$ and prove the following results.

\begin{thm}\label{envinv}
For all $w\in R(\cb)$, we have $\env_k w=\inv_k w$.
\end{thm}
\hyphenation{equi-distributed}
\begin{thm}\label{worddist}
The triples $(\des_k,\mad_k,\mak_k)$ and $(\exc_k,\inv_k,\den_k)$ are
equidistributed on $R(\cb)$.
\end{thm}

We will begin by recalling the definitions of $k$-descent and
$k$-excedance from \cite{CF1}.  Let $1\le i\le m$ and $w=a_1a_2\ldots
a_n\in R(\cb)$.  Let $\wb=b_1b_2\ldots b_n$ be the non-decreasing
rearrangement of $w$.  It is convenient to introduce a new small
letter $*$ such that $\ell<*<\ell+1$, and to put $w*=a_1a_2\ldots
a_n*$.  Thus we write $a_{n+1}=*$. (We use this convention throughout
the paper.)
%ES Transpose .) on preceding line (and in a couple of other places in
%the paper)?
%BOB  I'm not sure about this, but I suspect not, as the entire sentences is
%within parentheses.
We also introduce the following partial ordering on
$[m]*=[m]\cup\{*\}$.
\begin{defn}
If $a,b\in[m]$ then $a\prec b$ means either $a<b$ or $a=b$ with $b$ large.
Thus $a\not\prec b$ means either $b<a$ or $a=b$ with $b$ small.
\end{defn}
\begin{defn}
Let $w=a_1a_2\ldots a_n$ be a word with $\wb=b_1b_2\ldots b_n$.  A $k$-{\em
descent\/} in the word $w$ is a triple $(i,a_i,a_{i+1})$, where $1\le i\le n$,
such that $a_{i+1}\prec a_i$.  Here $i$ is called the $k$-{\em descent place\/},
$a_i$ is called the $k$-{\em descent top\/} and $a_{i+1}$ is called the $k$-{\em
descent bottom\/}. A $k$-{\em excedance\/} in $w$ is a triple $(i,a_i,b_i)$,
where $1\le i\le n$, such that $b_i\prec a_i$.  Here $i$ is called the $k$-{\em
excedance place\/}, $a_i$ is called the $k$-{\em excedance top\/} and $b_i$ is
called the $k$-{\em excedance bottom\/}. The numbers of $k$-descents and
$k$-excedances in $w$ are denoted by $\des_k w$ and $\exc_k w$ respectively.

The $k$-{\em descent set\/} of $w$, $D_k(w)$, is the set of $k$-descent places.
The $k$-{\em excedance set\/} of $w$, $E_k(w)$, is the set of $k$-excedance
places.
\end{defn}
This is a slight change of wording from \cite{CF1}.

\begin{defn}
The $k$-{\em major index} of $w$ is
$$\maj_k w=\sum_{i\in D_k(w)}i.$$
\end{defn}

Recall the $k$-extensions of $\imv$ and $\inv$ from \cite{F} and \cite{H}:
\begin{defn}
\begin{eqnarray*}
\inv_k w&=&\#\{\,(i,j)\mid i<j, a_j\prec a_i\,\}+\#\{\,i\mid a_i>\ell\};\\
\imv_k w&=&\#\{\,(i,j)\mid i<j, a_i\not\prec a_j\,\}.
\end{eqnarray*}
\end{defn}
Here, $\#S$ denotes the number of elements in the set $S$.

Let $i_1<i_2<\cdots<i_e$ be the increasing sequence of elements of $E_k(w)$ and
let $j_1<j_2<\cdots<j_{n-e}$ be the increasing complementary sequence in
$[n]$.
We form the {\em
excedance subword\/} $\EXC w=a_{i_1}a_{i_2}\ldots a_{i_e}$
and the {\em
non-excedance subword\/} $\NEX w=a_{j_1}a_{j_2}\ldots a_{j_{m-e}}$ of $w$.
 Put
$$
\ebot_k w=\sum_{i\in E_k(w)}i,
$$
that is,  $\ebot_k w$ is the sum of the $k$-excedance places in \w. 

\begin{remark}\rm%
Note that
$\ebot_k w$ is equal to the sum of the values of the $k$-excedance bottoms in
$\bar w$ if there are no large letters in \w\ as in \cite{CSZ},
but this is no longer true if there are large letters in \w, because of the $*$
and because we code equal large letters from right to left (See Section
\ref{height} below).
However, we use the notation $\ebot_k$ to be compatible
with \cite{CSZ}.
\end{remark}

The following
definition of $\den_k w$, from \cite{H}, is equivalent to the definition of
\cite{CF2}.
\begin{defn}
$$\den_k w=\ebot_k w+\imv_k\EXC w+\inv_k\NEX w.$$
\end{defn}
We can write the definition of $\den_k w$ in a slightly different way, using the
following definition.
\begin{defn}
  Let $w=a_1a_2\ldots a_n$ be a word.  If $i$ is a $k$-excedance place
  in \w\ then the $k$-{\em imversion bottom number\/} of $i$ is the
  number of places $j$ such that $1\le j<i$ and $a_j\not\prec a_i$.
  If $i$ is not a $k$-excedance place in \w\ then the {\em
    $k$-inversion top number\/} of $i$ is the number of places $j$
  such that $i<j\le n+1$ and $a_j\prec a_i$.  The {\em $k$-side
    number\/} $s_i$ of $i$ (in \w) is the $k$-imversion bottom number
or $k$-inversion top number of $i$ as appropriate.
\end{defn}
Clearly, the sum of the $k$-imversion bottom numbers for the letters
in $\EXC w$
equals $\imv_k\EXC w$, while the sum of the $k$-inversion top numbers for
the letters in $\NEX w$ equals $\inv_k\NEX w$.  We write
\begin{eqnarray*}
\ine_k w&=&\imv_k\EXC w+\inv_k\NEX w\\
&=&s_1+\cdots+s_n.
\end{eqnarray*}
Thus $\den_k w=\ebot_k w+\ine_k w$.

\begin{eg}\label{first}{\rm
Let
$$w=2\ 4\ 4\ 1\ 3\ 1\ 1\ 3,\quad\mbox{ so that }\quad\wb=1\ 1\ 1\ 2\ 3\ 3\ 4\
4.$$
Take $k=2$.  Thus 1 and 2 are small, while 3 and 4 are large.  There are
2-descent places at $i=2$, 3, 5 and 8.  Thus $\des_2 w=4$ and $\maj_2
w=2+3+5+8=18$.

There are 2-exedance places at $i=1$, 2, 3 and 5.  Thus $\exc_2 w=4$ and
$\ebot_2
w=11$.  Now, one readily checks that the sequence of side numbers of $w$ is
$(0,0,0,0,2,0,0,1)$.  Hence $\ine_2 w=3$ and $\den_2 w=14$.}
\end{eg}


\section{Further Mahonian statistics}
\subsection{Height and value}\label{height}
For each letter $a$, we define the {\em height\/} of $a$ in $w$ as
$$h_k(a)=h_{k,w}(a)=1+\#\{\,j\mid 1\le j\le n,a_j\prec a\,\}.$$
It is easy to see that
$$i\in E_k(w)\mbox{ if and only if }i<h_{k,w}(a_i).$$
%BOB n replaced by n+1 below.
If $1\le i\le n+1$, we define the {\em value\/} of the $i$-th letter in $w$ by
\begin{eqnarray*}
v_{k,i}=v_{k,i}(w)&=&\#\{\,j\mid j\le n+1,a_j<a_i\,\}\\
&&+\cases{
\#\{\,j\mid 1\le j\le i, a_j=a_i\,\},&if $a_i$ small;\cr
\#\{\,j\mid i\le j\le n, a_j=a_i\,\},&if $a_i$ large.\cr}
\end{eqnarray*}
Thus the height of a letter in a word is a function of the letter, not of its
position in the word, whereas the value of a letter does depend on its position
in the word.  Hence we can strictly only speak of the value of a position in
a word.

We will normally supress the argument $w$ to $v_k$ and $h_k$.

Using the relation $\prec$ we can write
\begin{equation}\label{value}
v_{k,i}=1+\#\{\,j\mid i<j\le n+1,a_j\prec a_i\,\}+\#\{\,j\mid 1\le
j<i,a_i\not\prec a_j\,\}.
\end{equation}

Notice that the word 
$$v_k(w)=v_{k,1}v_{k,2}\ldots v_{k,n}v_{k, n+1}$$
 is a
permutation.  In fact, our definition of $v_k(w)$ amounts to ``coding''
$w*$ to a
permutation by coding equal small letters from left to right and coding equal
large letters from right to left.  The equation
\begin{equation}\label{descents}
D_k(w)=D(v_k(w)),
\end{equation}
which is easily verified, is the motivation for this coding.
Note that, if $\w\in\sn$ is a permutation and $1\le i\le n$, then
$$v_{k,i}=h_k(a_i)=\cases{a_i,&if $1\le a_i\le\ell$,\cr
a_i+1,&if $\ell<a_i\le n$.\cr}$$
Further, $v_{k,n+1}=\ell+1$.

\begin{eg}\label{valueheight}{\rm
For the word $w=2\ 4\ 4\ 1\ 3\ 1\ 1\ 3$ considered in example \ref{first} with
$k=2$, we have $v_2(w)=4\ 9\ 8\ 1\ 7\ 2\ 3\ 6\ 5$.  Also $h_2(1)=1$,
$h_2(2)=4$, $h_2(3)=7$ and $h_2(4)=9$.}
\end{eg}
\subsection{The statistic $\env_k$}
Now we put
$$\ediff_k w=\sum_{i\in E_k(w)}(h_k(a_i)-i)$$
and we define a new statistic $\env_k w$ by
\begin{defn}
$$\env_k w=\ediff_k w+\imv_k\EXC w+\inv_k\NEX w.$$
\end{defn}

We can also write $\env_k w=\edif_k w+\ine_k w$.
For $k=0$, when there are no large letters, we have $\env_k=\env$, the
statistic defined in \cite{CSZ}.
\begin{eg}\label{env}{\rm
For the word $w=2\ 4\ 4\ 1\ 3\ 1\ 1\ 3$ considered above, we have
$\edif_2 w=(4-1)+(9-2)+(9-3)+(7-5)=18$ and $\env_2 w=18+3=21$.

One can easily check that $\inv_2 w=21$.}
\end{eg}
\begin{lem}\label{envdef} For any word $w$ we have
$$\env_k w=\sum_{i\in E_k(w)}(v_{k,i}-i)+\inv_k\EXC w+\inv_k\NEX w-\delta,$$
where $\delta$ is the number of large letters in $\EXC w$.
\end{lem}
\pf  Suppose that $\EXC w$ contains $d_a$ letters equal to
$a$, for $1\le a\le m$.  Then one can easily verify that
$$\imv_k\EXC w-\inv_k\EXC w
=\sum_{a=1}^l{d_a\choose2}-\sum_{a=l+1}^m{d_a+1\choose2}$$
and
$$\sum_{i\in E_k(w)}(v_{k,i}-h_k(a_i))
=\sum_{a=1}^l{d_a\choose2}-\sum_{a=l+1}^m{d_a\choose2},$$
bearing in
mind that the $d_a$ letters `$a$' occurring in $\EXC w$ will be the
left-most $d_a$ letters `$a$' that occur in $w$.  Hence the result
follows.  \qed

We can now prove that $\env_k$ and $\inv_k$ are identical.

\medskip
\noindent{\bf Proof of Theorem \ref{envinv}:\/}  From Lemma \ref{envdef} we
must show that
\begin{eqnarray}
\sum_{i\in E_k(w)}(v_{k,i}-i)
&=&\delta+\#\{\,(i,j)\mid i<j\le n,a_j\prec a_i,i\in E_k(w),j\not\in E_k(w)
\,\}\nonumber\\
&=&\delta+\sum_{i\in E_k(w)}
\#\{\,j\mid i<j\le n,a_j\prec a_i,j\not\in E_k(w)\,\}\nonumber\\
&=&\delta+\sum_{i\in E_k(w)}\big(\#\{\,j\mid i<j\le n,a_j\prec
a_i\,\}\nonumber\\
%BOB added "\le n" below.
&&\qquad-\#\{\,j\mid i<j\le n,a_j\prec a_i,j\in E_k(w)
\,\}\big)\label{invbit}.
\end{eqnarray}
%Jiang, please check
Now, since $i=\#\{\,j\mid j\le i\,\}$, it follows from equation
(\ref{value}) that
\begin{eqnarray}\label{envbit}
\sum_{i\in E_k(w)}(v_{k,i}-i)
&=&\sum_{i\in E_k(w)}(\#\{\,j\mid n+1\ge j>i,a_j\prec a_i\,\}\nonumber\\
&&\qquad\qquad \qquad-\#\{\,j\mid j<i,a_i\prec a_j\,\})\nonumber\\
%BOB added a little extra vertical space here.
\noalign{\vskip 10pt}
&=&\delta+\sum_{i\in E_k(w)}(\#\{\,j\mid n\ge j>i,a_j\prec a_i\,\}\nonumber\\
&&\qquad\qquad\qquad-\#\{\,j\mid j<i,a_i\prec a_j\,\}).
\end{eqnarray}
Hence, comparing equations (\ref{invbit}) and (\ref{envbit}), we need only to
 show that
$$
\sum_{i\in E_k(w)}\#\{\,j\mid i<j\le n,a_j\prec a_i,j\in E_k(w)\,\}
=\sum_{i\in E_k(w)}\#\{\,j\mid j<i,a_i\prec a_j\,\}.\nonumber
$$
But each of the sums in the above equation is $\inv_k\EXC w-\delta$.
\qed


\subsection{The statistics $\mad_k$ and $\mak_k$}

Let $w=a_1a_2\ldots a_n$ be a word, with $a_{n+1}$ as usual.  By analogy with
$\ebot_k w$ and $\ediff_k w$ we put
$$\dbot_k w=\sum_{i\in D_k(w)}v_{k,i+1}$$
and
$$\ddiff_k w=\sum_{i\in D_k(w)}(h_k(a_i)-v_{k,i+1}).$$

\begin{defn}
Let $w=a_1a_2\ldots a_n$ be a word.  For $1\le i\le n$, the {\em (right)
$k$-embracing number\/} $e_i$ in \w\ is
$$e_i=\cases{\#\{\,j\mid i<j\le n,a_{j+1}<a_i\le a_j\,\},&if $a_i$ is
small;\cr \#\{\,j\mid i<j\le n,a_{j+1}\le a_i<a_j\,\},&if $a_i$ is large.\cr}$$
The {\em (right) $k$-embracing sum\/} of \w\ is
$$\res_k w=e_1+\cdots+e_n.$$

\end{defn}
Alternatively, we may if we wish define $e_i$ for both small and large letters
$a_i$ by
$$e_i=\#\{\,j\mid i<j\le n,a_{j+1}\prec a_i,a_j\not\prec a_i\,\}.$$

\begin{defn}
 Let $w=a_1a_2\ldots a_n$ be a word.
 The $k$-descent $(j,a_j,a_{j+1})$ {\em embraces\/} $a_i$ if $a_{j+1}\prec
a_i$ and $a_j\not\prec a_i$.
\end{defn}
So $e_i$ is the number of $k$-descents in \w\ to the right of $a_i$ that
embrace $a_i$.

The statistics $\mad_k$ and $\mak_k$ can now be defined as follows:
\begin{defn}
\begin{eqnarray*}
\mad_k w&=&\ddiff_k w+\res_k w;\\
\mak_k w&=&\dbot_k w+\res_k w.
\end{eqnarray*}
\end{defn}


For $k=0$ we have $\mad_k=\mad$ and $\mak_k=\mak$ as defined in \cite{CSZ}.
Note that, for any word $w$, it follows from Equation (\ref{descents}) and from
\begin{equation}
\res_k w=\res_k v_k(w)
\end{equation}
that
$$\mak_k w=\mak_k v_k(w).$$
However, it is not in general true that $\mad_k w=\mad_k v_k(w)$.


\bigskip
In Section \ref{perms}, we will produce a bijection \phik\ on \sn\ such
that, for
all $\pi\in\sn$, we have
$$(\des_k,\mad_k,\mak_k)\ \pi=(\exc_k,\inv_k,\den_k)\phik(\pi).$$
In Section \ref{words}, we extend the definition of \phik\ to words, thereby
proving Theorem \ref{worddist}.
%BOB Example inserted below.
\begin{eg}\label{mad}{\rm
Consider the word
$$w=3\ 1\ 4\ 1\ 2\ 1\ 3\ 4,$$
with $k=2$.  Then
$$v_2(w)=7\ 1\ 9\ 2\ 4\ 3\ 6\ 8\ 5$$
and $h_2(1)=1$, $h_2(2)=4$, $h_2(3)=7$, $h_2(4)=9$.  Thus $\dbot_2
w=1+2+3+5=11$ and $\ddif_2 w=(7-1)+(9-2)+(4-3)+(9-5)=18$.  The sequence of
2-embracing numbers of $w$ is $(2,0,0,0,0,0,1,0,0)$, so $\res_2 w=3$.
Therefore $\mad_2 w=18+3=21$ and $\mak_2 w=11+3=14$.}
\end{eg}
 \section{The bijection for permutations}\label{perms}
Let $\p=a_1a_2\ldots a_n\in\sn$.  Then the set of $k$-descents in \p\ equals
the set of descents in $\p*$.  Hence $\dbot_k\p=\dbot\p*$ and
$\ddif_k\p=\ddif\p*$.  Moreover, if $(e_1,e_2,\ldots,e_n)$ is the sequence of
right $k$-embracing numbers of \p, the sequence of right embracing numbers of
$\p*$ is $(e_1,e_2,\ldots,e_n,0)$.  Thus $\res_k\p=\res\p*$.  Therefore
\begin{equation}\label{desk}
(\des_k,\mad_k,\mak_k)\ \p=(\des,\mad,\mak)\ \p*.
\end{equation}
Further, since $\exc_k\p=\exc_k\piti$, where
$$\piti=\pmatrix{1&2&\ldots&\ell&\ell+1&\ldots&n\cr
                 a_1&a_2&\ldots&a_\ell&a_{\ell+1}&\ldots&a_n\cr}
                        $$
and $\exc \pi*=\exc\pst$, where
$$
\pst=\pmatrix{1&2&\ldots&\ell&*&\ell+1&\ldots&n-1&n\cr
a_1&a_2&\ldots&a_\ell&a_{\ell+1}&a_{\ell+2}&\ldots&a_n&*\cr},
$$
it follows that there is a one-to-one correspondence between the $k$-excedances
of \p\ and the excedances of $\pi*$. For, if $a_i=i>\ell$ then $a_i>i-1$.  Thus
the set of $k$-excedance places of \p\ equals the set of excedance places of
$\pi*$ and the set of $k$-excedance tops of \p\ equals the set of excedance tops
of $\pi*$.  (The corresponding equality does {\em not\/} hold for the excedance
bottoms, but they play no explicit part in our statistics.) So
$\ebot_k\p=\ebot\p*$ and $\edif_k\p=\edif\p*$.  Similarly, we have that
$\ine_k\p=\ine\p*$, so that
\begin{equation}\label{exck}
(\exc_k,\env_k,\den_k)\ \pi=(\exc,\env,\den)\ \pi*.
\end{equation}

In \cite{CSZ}, a bijection $\Phi$ was constructed on \sn\ such that, for
all $\p\in\sn$,
\begin{equation}\label{desexc}
(\des,\mad,\mak)\ \p=(\exc,\env,\den)\ \Phi(\p).
\end{equation}
In order to prove Lemma \ref{last} below, we briefly describe the bijection
$\Phi$.  Let $F$, $F'$, $G$ and $G'$ denote respectively the sets of descent
bottoms, descent tops, non descent bottoms and non descent tops for \p.  Let $f$
and $g$ be the non-decreasing words formed from the letters of $F$ and $G$
respectively.  Let $f'$ and $g'$ be the words formed from the letters of
$F'$ and
$G'$ respectively, whose imversion bottom and inversion top numbers respectively
are the embracing numbers of those letters in \p. Form the biword
$$\alpha=\pmatrix{f&|&g\cr f'&|&g'\cr}.$$ Then the columns to the left of
the bar
are excedances, while those to the right are non-excedances.  Finally, rearrange
the columns of $\alpha$ so that its first row is increasing and read off the
permutation $\Phi(\pi)$ from the second row.

The bijection $\Phi$ has the following property.
\begin{lem}\label{last}
Let $\p=a_1a_2\ldots a_n\in\sn$ and let $\Phi(\p)=b_1b_2\ldots b_n$.  Then
$b_n=a_n$.  (That is, the bijection $\Phi$ fixes the last letter of a
permutation.)
\end{lem}
\pf Let $\p=a_1a_2\ldots a_n\in \sn$. Clearly, $a_n$ is a non-descent top
and its
(right) embracing number is zero. Hence $a_n$ will be a letter in $g'$ and all
the non-descent top letters smaller than $a_n$ will be to the left of $a_n$ in
$g'$. It remains to show that any non-descent top letter larger than $a_n$ will
not be the rightmost letter in $g'$. If $a_i$ $(i<n)$ is a non-descent top
letter
larger than $a_n$, then there is a letter $a_j$ $(i<j<n)$ such that $a_i<a_j$
(hence $a_j>a_n$), for, otherwise, $a_i$ would be a descent top. Let $a_j$
be the
smallest such letter. Thus $a_i>a_{j+1}$ and the embracing number of $a_i$ must
be larger than or equal to 1. This proves that $a_i$ cannot be the rightmost
letter in $g'$. \qed

Hence we define a bijection \phik\ on \sn\ by
$$
\p\mapsto\p*\mapsto\Phi(\p*)=\p'*\mapsto\p',
$$
where $\p'$ is a permutation.  It follows from Equations (\ref{desk}),
(\ref{exck}) and (\ref{desexc}) and Theorem \ref{envinv} that
\begin{equation}\label{desexck}
(\des_k,\mad_k,\mak_k)\ \p=(\exc_k,\inv_k,\den_k)\ \phik(\p).
\end{equation}
This proves Theorem \ref{worddist} in the case of permutations, that is, if all
$c_i\le1$.

We note for future reference that \phik\ satisfies a stronger property than that
specified in equation (\ref{desexck}), namely that the set of $k$-excedance
places of $\phik(\p)$ equals the set of $k$-descent bottoms of \p, the set of
$k$-excedance tops of $\phik(\p)$ equals the set of $k$-descent tops of \p\  and
the sequence of $k$-side numbers $s_1,s_2,\ldots,s_n$ of $\phik(\p)$ is a
permutation of the sequence of $k$-embracing numbers $e_1,e_2,\ldots,e_n$ of \p.
%BOB Example inserted below.
\begin{eg}\label{permphi}{\rm
Consider the permutation $\pi=6\ 1\ 8\ 2\ 4\ 3\ 5\ 7$ with $k=4$.  Thus
$\pi*=6\ 1\ 8\ 2\ 4\ 3\ 5\ 7\ *$, where $4<*<5$.  We may more conveniently
write $\pi*$ as $\tau=7\ 1\ 9\ 2\ 4\ 3\ 6\ 8\ 5$, a permutation on
$\{1,\ldots,9\}$.  Now, applying the bijection of \cite{CSZ} gives
$\Phi(\tau)=\tau'=4\ 8\ 9\ 1\ 7\ 2\ 3\ 6\ 5$.  Thus
$\pi'*=4\ 7\ 8\ 1\ 6\ 2\ 3\ 5\ *$ and $\Phi_2(\pi)=\pi'=4\ 7\ 8\ 1\ 6\ 2\ 3\
5$.
}\end{eg}
Although we can decompose \phik\ as the composition of two bijections
between the
{\it symmetric group} \sn\ and the {\it weighted Motzkin paths} as in
\cite{CSZ},
%BOB "an" added below.
this decomposition does not seem to yield an interesting continued fraction
expansion. Here we just record some partial results in this direction.

Let
$$
A_m^k(t,q)=\sum_{\p\in {\cal S}_n}t^{\exc_k \pi}q^{\expinv_k \pi}
$$
and
$$
A_m(x,y,t,q)=\sum_{k=0}^m{m\choose k}x^ky^{m-k}A_m^k(t,q).
$$
%Jiang the following values are added. Please check
%BOB "A_m^k(t,q)" replaced by "A_m(x,y,t,q)" below.
The first values of the polynomials $A_m(x,y,t,q)$ are as follows:
\begin{eqnarray*}
A_1(x, y, t,q)&=&y+xtq;\\
A_2(x, y, t,q)&=&y^2(1+tq)+2xyt(q+q^2)+x^2(tq^3+t^2q^2);\\
A_3(x, y, t,q)&=& y^3(1+ (2q+q^2+q^3)t+t^2q^2)\\
        &{}&+ 3xy^2((q+q^2+q^3+q^4)t+(q^2+q^3)t^2)\\
        &{}& +3x^2y((q^3+q^4)t+(q^2+q^3+q^4+q^5)t^2)\\
        &{}&+ x^3(q^5t+(2q^4+q^5+q^6)t^2+q^3t^3).
\end{eqnarray*}
It has been noted (see \cite{CF1}) that
$$
\sum_{m\geq 0}{u^m\over m!}A_m(x,y,t, 1)
={(1-t)\exp(uy(1-t))\over 1-t\exp(u(x+y)(1-t))}.
$$
Therefore, by applying the addition formula of Rogers -- Stieltjes
(see \cite{Z}) we can derive the following result.

\begin{prop} \label{frac}
 The ordinary generating function of $A_m(x, y, t, 1)$ has the following Jacobi
continued fraction expansion:
$$ \sum_{m\geq 0}A_m(x, y, t, 1)u^m
={1\over\displaystyle 1-b_0u- {\strut
\lambda_1u^2\over\displaystyle {}
{\strut \ddots\over\displaystyle 1-b_nu- {\strut
\lambda_{n+1}u^2\over\displaystyle \ddots }}}},
$$
where for $n\geq 0$,
\begin{eqnarray*}
b_n&=&(tx+y)(n+1)+(x+ty)n\\
\noalign{\vskip 5pt}
\lambda_{n+1}&=&(n+1)^2(x+y)^2t.
\end{eqnarray*}
\end{prop}

A combinatorial proof of the above result will eventually
produce a $q$-analogue of Proposition \ref{frac}.
More precisely, set $[n]_q=1+q+\cdots +q^{n-1}$ for $n\ge 1$ and $[0]_q=0$.
Since
$$
A_m^k(1,q)=\sum_{\p\in {\cal S}_n}q^{\expinv_k \pi}=q^kA_m^0(1,q),
$$
hence
$$
A_m(x,y,1,q)=\sum_{k=0}^m{m\choose k}(qx)^ky^{m-k}A_m^0(1,q)=(qx+y)^mA_m^0(1,q).
$$
We derive then from \cite[Theorem 10]{CSZ} the following result.

\begin{prop}\label{q-frac}
The ordinary generating function of $A_m(x, y, 1, q)$ has the following Jacobi
continued fraction expansion:
$$ \sum_{m\geq 0}A_m(x, y, 1,q)u^m
={1\over\displaystyle 1-b_0u- {\strut
\lambda_1u^2\over\displaystyle {}
{\strut \ddots\over\displaystyle 1-b_nu- {\strut
\lambda_{n+1}u^2\over\displaystyle \ddots }}}},
$$
where for $n\geq 0$,
\begin{eqnarray*}
b_n&=&q^n([n+1]_q+[n]_q)(qx+y), \\
\noalign{\vskip 5pt}
\lambda_{n+1}&=&q^{2n+1}[n+1]_q^2(qx+y)^2.
\end{eqnarray*}
\end{prop}

However, the series $\sum_{m\geq 0}A_m(x, y, t,q)u^m$ does not seem to have
a nice
Jacobi continued fraction expansion. In fact, suppose
$$ \sum_{m\geq 0}A_m(x, y, t,q)u^m
={1\over\displaystyle 1-b_0u- {\strut
\lambda_1u^2\over\displaystyle {}
{\strut \ddots\over\displaystyle 1-b_nu- {\strut
\lambda_{n+1}u^2\over\displaystyle \ddots }}}},
$$
then we find $b_0=tqx+y$, $\lambda_1=q\left (qx+y\right )^{2}t$ and
\begin{eqnarray*}
b_1&=&q(y^{3}q+y^{3}t+y^{3}+x^{3}q^{3}+tq^{3}x^{3}\\
&&\qquad +x^{3}tq^{4}-xy^{2}+3\,qxy^{2}+3\,xy^{2}q^{2}\\
&&\qquad + xy^{2}t+3\,xy^{2}tq+x^{2}yq+3\,yq^{2}x^{2}\\
&&\qquad +3\,tq^{2}x^{2}y+3\,x^{2}ytq^{3}-x^{2}ytq)/ (qx+y)^{2}.
\end{eqnarray*}

\section{Working with words}\label{words}
%BOB Paragraph slightly rephrased below to correct omission of n+1.
Let $w=a_1a_2\ldots a_n\in R(\cb)$ and let $\pi*=v_k(w)=v_1v_2\ldots v_nv_{n+1}$
as defined in Section \ref{height}. (Here, we are identifying $*$ with
$v_{n+1}$.)  Apply the bijection \phik\ of Section \ref{perms} to \p\ to
obtain a
permutation $\pi'=v'_1v'_2\ldots v'_n$.  Finally, {\em decode\/} \pp\ by
replacing each letter $x$ of \pp\ by a letter $a_i$ of \w\ such that
$v_{k,i}(w)=x$, to obtain a word $w'=a'_1a'_2\ldots a'_n$.  The mapping \phikw\
is then defined on $R(\cb)$ by $\phikw(w)=w'$.

We introduce two pieces of notation to aid in the proof of Theorem
\ref{worddist}.  Firstly, let the rightmost occurence of the largest small
letter
$\ell$ in \w\ be coded to the letter $L$.  Then for any letter $a_i$ in \w,
$a_i$
is small if and only if $v_i\le L$.  Secondly, write $\theta$ as the decoding
map. Thus $a_i=\theta(x)$ if $v_{k,i}(w)=x$.

\bigskip
\noindent{\bf Proof of Theorem \ref{worddist}:}  We shall show that \phikw\ is a
bijection on $R(\cb)$ such that for all $w\in R(\cb)$, we have
\begin{equation}\label{desexcw}
(\des_k,\mad_k,\mak_k)\ w=(\exc_k,\inv_k,\den_k)\ \phikw(w).
\end{equation}

By equation (\ref{descents}), we have $D_k(\pi)=D_k(w)$, and moreover the
sequence of $k$-embracing numbers of \p\ equals the sequence of $k$-embracing
numbers of \w.  By the remark following the proof of equation
(\ref{desexck}), it
follows that the set of $k$-excedance places of \pp\ equals the set of
$k$-descent bottoms of \w, the set of $k$-excedance tops of \pp\ equals the set
of $k$-descent tops of \w\ and that the sequence of $k$-side numbers of
\pp\ is a
permutation of the sequence of $k$-embracing numbers of \w.

To complete the proof of equation (\ref{desexcw}), we must look in
more detail at the construction of \phikw, derived from the
construction of $\Phi$ given above.  Let $F$, $F'$, $G$ and $G'$
denote respectively the sets of descent bottoms, descent tops, non
descent bottoms and non descent tops for $\pi*$.  We note that each of
the above sets is the image under $v_k$ of the corresponding $k$-set
for $w*$.  Let $f$ and $g$ be the non-decreasing words formed from the
letters of $F$ and $G$ respectively.  Let $f'$ and $g'$ be the words
formed from the letters of $F'$ and $G'$ respectively, whose imversion
bottom and inversion top numbers respectively are the embracing
numbers of those letters in $\pi*$, that is, the $k$-embracing numbers
of the corresponding letters in \w. Form the biword
$$\alpha=\pmatrix{f&\mid&g\cr f'&\mid&g'\cr}.$$
Then the columns to
the left of the bar are excedances, while those to the right are
non-excedances.  Finally, rearrange the columns of $\alpha$ to form
the biword \ppst\ and read off the permutation $\pi'*$ from the second
row.  We must show that the excedances in $\alpha$ correspond
precisely to the $k$-excedances in \wwt.

First we note that the column $\pmatrix{a\cr b\cr}$ of $\alpha$ corresponds to
the column $\pmatrix{a\cr b\cr}$ of \ppst\ and thence either to the column
$\pmatrix{a\cr b\cr}$ or to the column $\pmatrix{a+1\cr b\cr}$ of \ppt\
according
as $a\le L$ or $a>L$.

\bigskip
\noindent{\bf Case 1:} The column $\pmatrix{a\cr b\cr}$ of $\alpha$ is an
excedance.

Then $a$ is a descent bottom and $b$ is a descent top in $\pi*$.

\medskip
\noindent{\em Case 1(i):} $b\le L$.

Then $a<L$.  So there is a column $\pmatrix{a\cr b\cr}$ in \ppt\
corresponding to
a column $\pmatrix{\theta(a)\cr\theta(b)\cr}$ in \wwt.  Now the proof that
$\pmatrix{\theta(a)\cr\theta(b)\cr}$ is an excedance (which in this case is the
same as a $k$-excedance, as $\theta(b)$ is small), follows exactly as in Section
4 of \cite{CSZ}.

\medskip
\noindent{\em Case 1(ii):} $b)>L$.

If $a\le\ell$ then, as before, the corresponding column in \wwt\  is
$\pmatrix{\theta(a)\cr\theta(b)\cr}$, which is a $k$-excedance as
$\theta(a)<\theta(b)$. If $a>L$ then, as $a<b$, $a+1\le b$ and so
$\theta(a+1)\le\theta(b)$.  Therefore the corresponding column
$\pmatrix{\theta(a+1)\cr\theta(b)\cr}$ of \wwt\ is a $k$-excedance, as
$\theta(b)$ is large.

\bigskip
\noindent{\bf Case 2:} The column $\pmatrix{a\cr b\cr}$ of $\alpha$ is a
non-excedance.

Then $a$ is a non descent bottom and $b$ is a non descent top in $\pi*$.

\medskip
\noindent{\em Case 2(i):} $b\le L$.

Then $a\ge b$, so that $\theta(a)\ge\theta(b)$. Now if $a>L$ then the column
$\pmatrix{a+1\cr b\cr}$ occurs in \ppt\ and the corresponding column in \wwt\ is
$\pmatrix{\theta(a+1)\cr\theta(b)\cr}$, which is a non-$k$-excedance as
$\theta(b)$ is small.  If $a\le L$ then the column $\pmatrix{a\cr b\cr}$ occurs
in \ppt\ and the corresponding column in \wwt\ is
$\pmatrix{\theta(a)\cr\theta(b)\cr}$, which is a non-$k$-excedance as
$\theta(b)$ is small.

\medskip
\noindent{\em Case 2(ii):} $b>L$.

Then also $a>L$, so the column in \wwt\ corresponding to the column
$\pmatrix{a\cr b\cr}$ of \ppst\ is $\pmatrix{\theta(a+1)\cr\theta(b)\cr}$, which
we must show is a non $k$-excedance.  Now, let $b_1$ be the smallest letter such
that $b_1>b$, $\theta(b_1)=\theta(b)$ and $b_1$ occurs to the right of $b$
in the
second row of $\alpha$ (that is, in the word $g'$).  We will show that no such
letter $b_1$ exists.  Now such a $b_1$ must occur to the left of $b$ in the word
\w, as large letters in \w\ are coded from right to left.  So the $k$-embracing
numbers of $b$ and $b_1$ in \w\ satisfy $e(b_1)\ge e(b)$.  But as $b_1$
occurs to
the right of $b$ in $g$ and there is no letter $c$ to the right of $b$ in $g$ in
the range $b<c<b_1$, the inversion top numbers of $b$ and $b_1$ in $g$ satisfy
$s(b_1)\le s(b)$.  By the construction of $g$ we have $s(b_1)=e(b_1)$ and
$s(b)=e(b)$.  Hence $e(b_1)=e(b)$.  Hence there can be no letter between $b_1$
and $b$ in \w\ that is greater than $b$.  Hence $b_1$ is a descent top, and
cannot be a letter of $g$.  Hence we have shown that no letter $c>b$ with
$\theta(c)=\theta(b)$ occurs to the right of $b$ in $g$. Therefore, if $b$
occurs
in the $p$-th column from the right of $g$, we have
\begin{eqnarray*}
p&\le&1+e(b)+\#\{\,j\mid j\in G',\theta(a_j)>\theta(b)\,\}\\
&\le&1+\#\{\,j\mid j\in G,\theta(a_j)>\theta(b)\,\}.
\end{eqnarray*}
For to every $k$-descent of \w\ to the right of $b$ that embraces $b$
there corresponds a non $k$-descent bottom of \w\ to the right of \w\ that
is greater
than $b$, and to every non $k$-descent top of \w\ that is greater than $b$
there corresponds a non $k$-descent bottom of \w\ that is greater than $b$.
Thus we have $\theta(a+1)>\theta(b)$ as required.

\bigskip It now follows that the set of $k$-excedance places in \ww\
equals the set of excedance places in $\pi'*$, that is, the set of
$k$-excedance places in \pp.  Similarly, the set of $k$-excedance tops
in \ww\ equals the set of $k$-excedance tops in \pp.  Now, by the
previous argument, $\EXC{w'}=\theta(f')$ and $\NEX{w'}=\theta(g'')$
(where $g''$ is obtained from $g'$ by stripping off the final letter $*$.)
By the proof of Case 2(ii) above, $\inv_k\NEX{w'}=\inv\NEX{\pi'*}$,
and by a similar argument, $\imv_k\EXC{w'}=\imv\EXC{\pi'*}$.  Thus
$\ine_k w'=\ine\pi'*=\ine_k\pi'$. Hence equation (\ref{desexcw})
follows.

\bigskip
To complete the proof, we must show that \phikw\ is a bijection.  The proof is
not essentially different from that presented in \cite{CSZ} for the mapping
\phiw, that is, for the case $k=0$, but for completeness we set down the proof
here.

It clearly suffices to show that \phikw\ is an injection.  Suppose that for
words
$w_1$ and $w_2$ we have
$$w_t\mapsto\pi_t=v_k(w_t)\mapsto\pi'_t=\Phi(\pi_k)\mapsto w'$$
for $t=1, 2$.  Since the map $w_t\mapsto\pi'_t$ is clearly an injection, it
suffices to prove that $\pi'_1=\pi'_2$.  We refer to the sets and words involved
in the construction of $\phikw(w_t)$ by $F_t$, $f_t$, $G_t$, etc., for $t=1, 2$.
Now $F_t=E(\pi'_t)=E(w'), =\{i_1,i_2,\ldots,i_r\}$, say, for $t=1,  2$,  and
$G_t$  is  the  complementary set.  Hence the words $f_t$ and $g_t$ can be
determined. Further, $f'_t$ is an inverse image under $\theta$ of the word
$a_{i_1}a_{i_2}\ldots a_{i_r}$, and we have a similar result for $g'_t$.  We can
calculate the side numbers of $\pi'_t$, as these equal the side numbers of \ww.
Now we can recover $f'_t$ and $g'_t$, provided that we can determine the
relative
size of any two letters of these words that have the same image under $\theta$.
Suppose that $\theta(v'_i)=\theta(v'_j)=a$ for letters $v'_i$ and $v'_j$ of
$\pi'_t$.  We distinguish several cases.

\begin{enumerate}
\item Suppose that $s(v'_i)>s(v'_j)$.  Then $v'_i$ must occur to the left of
$v'_j$ in the word $\pi_t$.  Hence, by the way in which the value $v(w_t)$ is
defined, $v'_i>v'_j$ or $v'_i<v'_j$ according as $a$ is large or small.
\item Suppose that $s(v'_i)=s(v'_j)$.
%BOB The previous part (b) was not correct, as $v'_i$ and $v'_j$ could both
%belong to $F'_t$ with equal side numbers if they correspond to the same large
%letter.  I have renumbered this part as (c) and referred in it to part (b).
\begin{enumerate}
\item If $v'_i\in F'_t$ and $v'_j\in G'_t$ then $v'_i$ is a descent top in
$\pi_t$ and $v'_j$ is not a descent top in $\pi_t$.  Hence $v'_i$ must occur to
the left of $v'_j$ in the permutation $\pi_t$, otherwise
$s(v'_j)=e(v'_j)>e(v'_i)=s(v'_i)$.  Thus $v'_i>v'_j$ or $v'_i<v'_j$ as in the
previous case.
\item Let $v'_i,v_j\in G'_t$ with $i<j$.  We may assume that $\theta(v'_m)\ne a$
for any $m$ between $i$ and $j$. Then $v'_i<v'_j$, for otherwise $(i,j)$
would be
an inversion in $\pi'_t$ and we would have $s(v'_i)\ne s(v'_j)$.
\item Let $v'_i,v'_j\in F'_t$ with $i<j$.  Then both $v'_i$ and $v'_j$ are
descent tops in $\pi_t$.  Hence $a$ must be a large letter.  As in the
previous case, we have $v'_i<v'_j$.
\end{enumerate}
\end{enumerate}
Hence $f'_t$ and $g'_t$ are completely determined by \ww.  Thus $\pi'_1=\pi'_2$
and \phikw\ is an injection.

This completes the proof of Theorem \ref{worddist}.  \qed
%BOB Example inserted below.
\begin{eg}{\rm
Consider the word $w=3\ 1\ 4\ 1\ 2\ 1\ 3\ 4$ of example \ref{mad},
with $k=2$.  Write $\pi*=v_2(w)=7\ 1\ 9\ 2\ 4\ 3\ 6\ 8\ 5$.
As in example \ref{permphi} we have
$\pi'*=\Phi_2(\pi)*=4\ 8\ 9\ 1\ 7\ 2\ 3\ 6\ 5$.  Decoding $\pi$ then gives
$w'=\Phi_{2,\mbox{$\mn\scriptscriptstyle W$}}(w)=2\ 4\ 4\ 1\ 3\ 1\ 1\ 3$.  From
examples \ref{first}, \ref{env} and \ref{mad} we have
\begin{eqnarray*}
(\des_2,\mad_2,\mak_2)\ w&=&(\exc_2,\inv_2,\den_2)\ w'\\
&=&(4,21,14).
\end{eqnarray*}}
\end{eg}

\begin{thebibliography}{99}
\bibitem{CF1}  R . J. Clarke and D. Foata: Eulerian Calculus I: Univariate
statistics, Europ. J. Combinatorics {\bf 15} (1994), 345--362.

\bibitem{CF2}   R. J. Clarke and D. Foata: Eulerian Calculus II: An extension
of Han's fundamental transformation, Europ. J. Combinatorics {\bf 15} (1994),
345--362.


\bibitem{CSZ}  R. J. Clarke,  E. Steingr\'{\i}msson and J. Zeng: New
Euler-Mahonian statistics on permutations and words, to appear in
 Adv. Appl. Math.

\bibitem{F} D. Foata: Unpublished note (1993).

\bibitem{H} G.-N. Han: The $k$-extension of a Mahonian statistic,
  Adv. Appl. Math., {\bf 16} (1995), 297--305.

\bibitem{Z} J. Zeng: Enum\'{e}rations de permutations et $J$-fractions
 continues, Europ. J. Combinatorics, {\bf 14} (1993), 373--382.

\end{thebibliography}

\end{document}
