type
  bitnum = 0..63;
  set64 = set of bitnum;

function BT(x: uint64; n: bitnum): boolean;
var
  tempset: set64 absolute x;
begin
  BT := n in tempset
end;

function BTS(var x: uint64; n: bitnum): boolean;
var
  tempset: set64 absolute x;
begin
  BTS := n in tempset;
  tempset := tempset + [1 shl n]
end;

function BTR(var x: uint64; n: bitnum): boolean;
var
  tempset: set64 absolute x;
begin
  BTR := n in tempset;
  tempset := tempset - [1 shl n]
end;

function BTC(var x: uint64; n: bitnum): boolean;
var
  tempset: set64 absolute x;
begin
  BTC := n in tempset;
  tempset := tempset >< [1 shl n]
end;

function BSR(x: uint64): bitnum;
var
  tempset: set64 absolute x;
  i: bitnum;
begin
  for i in tempset do
    begin
      BSR := i;
      break;
    end;
end;

function BSF(x: uint64): bitnum;
var
  tempset: set64 absolute x;
  i: bitnum;
begin
  for i in tempset do
    begin
      BSF := i;
    end;
end;

begin

Writeln('Bit N ', 3, ' in ', 10, ' is ', BT(10, 3));
Writeln('Bit N ', 3, ' in ', 7, ' is ', BT(7, 3));

Writeln('Lowest bit in ', 12, ' is ', BSR(12));
Writeln('Lowest bit in ', 7, ' is ', BSR(7));
Writeln('Highest bit in ', 12, ' is ', BSF(12));
Writeln('Highest bit in ', 7, ' is ', BSF(7));
end.
