A number N is given. Find its Kth Least Significant Bit.
Example 1:
Input: N = 10, K = 4
Output: 1
Explanation: Binary Representation 
of 10 is 1010. 4th LSB is 1.
Example 2:
Input: N = 16, K = 3 
Output: 0 
Explanation: Binary Representation of 
16 is 10000. 3rd LSB is 0.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function KthLSB() which takes the N and K as inputs and returns the bit (1 or 0) in K'th LSB.
Expected Time Complexity: O(K)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{9}
1 ≤ K ≤ 32

Difficulty: EASY
Tags: Bit manipulation

Data structures
Skill types: Bit manipulation

Data structures
Expected Time Complexity: O(K)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
	def KthLSB(self, n, k):
		# code here

Solutions:
class Solution:

	def KthLSB(self, n, k):
		if n & 1 << k - 1 != 0:
			return 1
		return 0


class Solution:

	def KthLSB(self, n, k):
		count = 0
		while n != 0:
			bit = n & 1
			count += 1
			if count == k:
				return bit
			n = n >> 1
		return 0


class Solution:

	def KthLSB(self, n, k):
		x = bin(n)[2:][::-1]
		if len(x) < k:
			return 0
		return x[k - 1]


class Solution:

	def KthLSB(self, n, k):
		num = bin(n)[2:]
		num = num[::-1] + 32 * '0'
		return num[k - 1]


class Solution:

	def KthLSB(self, n, k):
		return int(bool(n & 1 << k - 1))


class Solution:

	def KthLSB(self, n, k):
		return n >> k - 1 & 1


class Solution:

	def KthLSB(self, n, k):
		l = bin(n)[2:]
		if k > len(l):
			return 0
		else:
			return l[len(l) - k]


class Solution:

	def KthLSB(self, n, k):
		n = bin(n).replace('0b', '')[::-1]
		try:
			return n[k - 1]
		except:
			return 0


class Solution:

	def KthLSB(self, n, k):
		m = bin(n).replace('0b', '')[::-1]
		if len(m) < k:
			return 0
		else:
			return m[k - 1]


class Solution:

	def KthLSB(self, n, k):
		try:
			return bin(n)[2:][-k]
		except:
			return 0


class Solution:

	def KthLSB(self, n, k):
		return 1 if bool(n & 1 << k - 1) else 0


class Solution:

	def KthLSB(self, n, k):
		for i in range(0, k - 1):
			n = n >> 1
		return n & 1


class Solution:

	def KthLSB(self, n, k):
		n = bin(n)
		n = n[:1:-1]
		if k > len(n):
			return 0
		return n[k - 1]
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(n, k) = input().split(' ')
		n = int(n)
		k = int(k)
		ob = Solution()
		ans = ob.KthLSB(n, k)
		print(ans)


import math

class Solution:

	def KthLSB(self, n, k):
		return n >> k - 1 & 1
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(n, k) = input().split(' ')
		n = int(n)
		k = int(k)
		ob = Solution()
		ans = ob.KthLSB(n, k)
		print(ans)


class Solution:

	def KthLSB(self, n, k):
		bit = 1 << k - 1
		new_num = bit & n
		if new_num > 0:
			return 1
		else:
			return 0


class Solution:

	def KthLSB(self, n, k):
		mask = 1 << k - 1
		x = n & mask
		if x == 0:
			return 0
		else:
			return 1


class Solution:

	def KthLSB(self, n, k):
		x = bin(n).replace('0b', '')
		x = str(x)
		if len(x) < k:
			return 0
		else:
			y = len(x) - k
			return x[y]


class Solution:

	def KthLSB(self, n, k):
		j = '{:032b}'.format(n)
		return j[len(j) - k]


class Solution:

	def KthLSB(self, n, k):
		a = bin(n).replace('0b', '00')
		if k > len(a):
			return '0'
		else:
			x = -k
			return a[x]


class Solution:

	def KthLSB(self, N, k):
		count = 0
		while N:
			count += 1
			if count == k:
				return N & 1
			N = N >> 1
		return 0


class Solution:

	def KthLSB(self, n, k):
		a = bin(n)[2:]
		b = len(a)
		if k <= b and a[b - k] == '1':
			return 1
		return 0


class Solution:

	def KthLSB(self, num, K):
		return int(bool(num & 1 << K - 1))


class Solution:

	def KthLSB(self, n, k):
		n = bin(n).replace('0b', '').zfill(32)[::-1]
		return n[k - 1]


class Solution:

	def KthLSB(self, n, k):
		for i in range(k):
			a = n % 2
			n //= 2
		return a


class Solution:

	def KthLSB(self, n, k):
		s = ''
		while n:
			s += str(n % 2)
			n //= 2
		s = s[::-1]
		if len(s) < k:
			return 0
		for i in range(len(s) - 1, -1, -1):
			if k == 1:
				return s[i]
				break
			k -= 1


class Solution:

	def KthLSB(self, n, k):
		b = bin(n)
		if k > len(b) - 2:
			return 0
		return b[-k]


class Solution:

	def KthLSB(self, n, k):
		a = 1
		while n > 0:
			b = n % 2
			if a == k:
				return b
			a = a + 1
			n = n // 2
		return 0


class Solution:

	def KthLSB(self, n, k):
		1010
		temp = n
		bit = 0
		while temp > 0:
			bit += 1
			if bit == k:
				return temp % 2
			temp //= 2
		return 0


class Solution:

	def KthLSB(self, n, k):
		m = 0
		j = 0
		m = n >> k - 1
		j = m & 1
		return j


class Solution:

	def KthLSB(self, n, k):
		res = bin(n)[2:]
		l = list(res)
		if k > len(l):
			return 0
		return l[-k]