How to position the default blender cube given coordinates, direction Z vector and direction Y vector using python?
make a 3 x 3 rotation matrix with X, Y and Z axis as columns. Blender matrices are in rows, so will transpose rows to columns. The X axis is Y.cross(Z). 

Make the matrix a 4x4 transform matrix and set its translation to coordinate  

Note Added a scale factor so location 1000 -> 10. To avoid clipping. Set to 1 or remove.  

import bpy
from mathutils import Matrix, Vector

context = bpy.context
scale = 0.01 # 1000 is a long way away

x, y, z, l, m, n, p, q, r = -500, 200, 1000, 1, 0, 0, 0, 0, -1

y_axis = Vector((l, m, n)).normalized()
z_axis = Vector((p, q, r)).normalized()

x_axis = y_axis.cross(z_axis).normalized()

M = Matrix((x_axis, y_axis, z_axis)).transposed()

M = M.to_4x4()

M.translation = scale * Vector((x, y, z))

#test
print(M)
print(x_axis, y_axis, z_axis)
bpy.ops.object.empty_add()
mt = context.object
mt.empty_display_type = 'ARROWS'
mt.matrix_world = M


or to  add a cube 

#test
bpy.ops.mesh.primitive_cube_add()
cube = context.object
cube.matrix_world = M