A structural insight into mechanical strength of graphene-like carbon and carbon nitride networks