Based on what we've got so far, this could be what you want:
--=======================================================
-- Test data:
--=======================================================
drop table #temp;
create table #temp
(
col1 int,
col2 char(1),
col3 char(1),
col4 char(3)
);
insert #temp values ( 1, 'X', 'M', 'abc' );
insert #temp values ( 2, 'X', 'M', 'pqr' );
--=======================================================
-- Solution:
--=======================================================
select
col1=col2,
col2=col3,
col3=max(case when col1=1 then col4 else null end),
col4=null,
col5=max(case when col1=2 then col4 else null end),
col6=null
from #temp
group by col2, col3;