# Import the NumPy library
import numpy as np
# Creating two 1D arrays
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
# Compute cartesian product
A, B = np.meshgrid(a, b)
# Flatten and stack arrays
cartesian_product = np.stack((A.flatten(), B.flatten()), axis=1)
# Print cartesian product
print(cartesian_product)