Find the last position in a matrix walking like a spiral This question will be deleted soon, do not read/answer it

Introduction

Given one matrix A x A and a number of movements N.

You will need to walk like a spiral starting in (1; 1):


right while possible, then 
down while possible, then
left while possible, then
up while possible, repeat until got N.


Challenge

You can only take as input the numbers A and N.

You must output the final (row; column) after walking N steps in the conditions explained above. You can not invert the output order.

You can use indexes starting with zero as well. Just state it in your answer.

Program or function allowed.

This is code-golf, shortest answer in bytes wins.

Sample

For input (A = 8; N = 54).



The output should be (5; 6).

Another samples

input: A=8, N=64
output: [5, 4]




input: A=15, N=14
output: [1, 14]




input: A=26, N=400
output: [22, 9]




input: A=1073741824, N=1152921504603393520
output: [536871276, 536869983]


Restrictions

1 &lt;= A &lt;= 230

1 &lt;= N &lt;= (A2 OR the below higher number supported in your language).



And, if you want a generic formula.
MATL, 24 bytes
This works in release 16.0.0 of the language, which predates the challenge.
2^Q6Y3GYLG2\?!P!}P]-=2#f

Output is 1-based, as in the examples.
A^2 and N are limited to 2^53 as per the language's default data type (double). In addition, since the whole matrix is being generated, memory will limit A to significantly lower values.
Try it online! (In the online version I have changed the order of G and 6Y3 so it works in the new 16.1.0 release)
Explanation
This uses MATL's builtin for generating an outward spiral. To make it inward, a subtraction and a reversal are needed. The direction of reversal depends on whether A is odd or even.
2^Q     % take input A implicitly. Compute A^2+1
6Y3GYL  % outward spiral of side length A
G2\     % is A odd?
?       % if so
  !P!   %   flip matrix horizontally
}       % else
  P     %   flip matrix vertically
]       % end if
-       % compute A^2+1 minus the matrix element-wise, so (1,1) contains 1
=       % take input N implicitly. Set matrix entry that contains that value to true
2#f     % row and column index of that true value