Order and Chaos and Codegolf Order and Chaos is a variant of Tic-Tac-Toe played on a 6x6 board. What makes the game unique, however, is that both players can place either an X or an O! Each turn (starting with Order), a player places an X or O in any unoccupied square.
Winning is simple. Order wins if there are 5 Xs or Os (vertically, horizontally, or diagonally) in a row on the board. Chaos wins if the board is filled and there are no strings of 5 Xs or Os on the board. Your job? Well, since this is Programming Puzzles and Code Golf, you're going to program the game, and golf it.
The Rules

You must accept input as x y t, where x and y are coordinates, and t is the tile type (X or O). Coordinates start with 0 0 in the upper-left corner and increase up to 5 5 (the lower-right corner).
You must accept q to quit, and print INVALID if the user enters invalid coordinates, tiles, any input not in the form of x y t, or tries to place a tile where there already is one. (The only exception is q, as this quits the program.)
If Order wins, you will output P1 WINS. If Chaos wins, you will output P2 WINS.
Order must go first.
A blank space is represented by ..
Tiles are X and O (uppercase). You do not have to accept lowercase, but uppercase is required.
Your board must only consist of .XO.
You're actually simulating both players playing the game, not being given a board and checking who wins. It accepts a move as input, then prints the board, accepts another move, and so on, until one player wins.

The starting board looks like this:
......
...... 
......
......
......
...... 

And after the first player (Order) inputs 1 2 X, it should look like this:
......
...... 
.X....
......
......
......  

Likewise, when the next player (Chaos) inputs 3 3 O, it will look like this:
......
...... 
.X....
...O..
......
......  

And this continues until one player wins.
As always, Standard loopholes which take the fun out of everything are forbidden.
The winner is the one with the shortest code on June 15, 00:00 UTC (about one month from when this challenge was posted.)
JavaScript, 360

Edit Modified interactive game, should run even in MSIE

As requested, text based game, input via popup, output in console (so to have a monospaced font).

Quit game with 'q' or clicking 'cancel' at prompt.

Not using ES5 features, it should run on any moder browser (where you can have a JS console panel)



b='\n......'.repeat(6).split('');
for(h=t=0;!h&amp;t&lt;36;)
{
  i=prompt();
  if(i=='q')i=null;
  i=i.match(/([0-5]) ([0-5]) ([XO])/);
  m='INVALID';
  if(b[p=i?i[2]*7-~i[1]:0]=='.')
  {
    ++t;
    b[p]=i[3];
    m=b.join('');
    for(x=z='',c=0;c++&lt;6;)
      for(x+='_',z+='_',r=0;r&lt;6;r++)
        x+=b[c+r*7],z+=b[c&lt;4?c-1+r*8:c+1+r*6];
    h=(/X{5}|O{5}/.test(b.join('')+x+z))
  }
  console.log(m);
}
console.log("P"+(2-h)+" WINS")




Now, some more fun Interactive and graphic version, run snippet to play.



function start() {
  b=Array(7).join('\n......').split('');
  t=0;
  $('#O').text('');
  $('table')[0].className='';
  show();
  $('th').eq(1).html('Left-click: O&lt;br&gt;Right-click: X');
  $('#B')
  .off('mouseup')
  .on('mouseup','td.F',function(ev){
    var x,y, p=~~this.id.slice(1)
    x=p%7-1
    y=p/7|0
    b[p]=ev.which &gt; 1 ?'X':'O';
    ++t
    for(x=z='',c=0;c++&lt;6;)
      for(x+='_',z+='_',r=0;r&lt;6;r++)
        x+=b[c+r*7],z+=b[c&lt;4?c-1+r*8:c+1+r*6];
    show()
    if (/X{5}|O{5}/.test(b.join('')+x+z))
      end(1)
    else if(t==6*6) 
      end(2)
    return false
  })
}

function end(w) {
  var n=['Order','Chaos'][w-1]
  $('th').eq(0).text('P'+w+' '+n+' Wins')
  $('th').eq(1).text('Click to play again')
  
  $('table')[0].className=$('tr')[0].className =n[0];
  $('#B').off('mouseup').on('mouseup', start)
}
function show() {
  var w,p
  p=t&amp;1
  $('tr')[0].className=$('#B')[0].className='OC'[p];
  w=b.map(function(c,i){
    return c&gt;' '?'&lt;td class='+(c=='.'?'F':'X')+' id=C'+i+'&gt;'+c+'&lt;/td&gt;':'&lt;/tr&gt;&lt;tr&gt;'
  }).join('');
  $('th').eq(0).text('Playing: '+['Order','Chaos'][p]);
  $('#B').html('&lt;tr&gt;' + w +'&lt;/tr&gt;');
}

start()
th { 
  font-size: 12px;
}
.C th { color: #807; }
.O th { color: #047; }
.C td.F:hover { background: #f0e; }
.O td.F:hover { background: #0fe; }
table.C td { background: #f0e; }
table.O td { background: #0fe; }

td {
  font-family: monospace;
  font-size: 12px;
  width: 1.2em;
  height: 1em;
  text-align: center;
}
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;table&gt;
  &lt;tr&gt;&lt;th colspan=6&gt;&lt;/th&gt;&lt;/tr&gt;
  &lt;tbody id=B&gt;&lt;/tbody&gt;
  &lt;tr&gt;&lt;th colspan=6&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p id=O&gt;&lt;/p&gt;