  We show that some ternary quasigroups appear naturally as invariants of
classical links and links on surfaces. We also note how to obtain from them
invariants of Yoshikawa moves. In our previous paper, we defined homology
theory for algebras satisfying two axioms derived from the third Reidemeister
move. In this paper, we show a degenerate subcomplex suitable for ternary
quasigroups satisfying these axioms, and corresponding to the first
Reidemeister move. For such ternary quasigroups with an additional condition
that the primary operation equals to the second division operation, we also
define another subcomplex, corresponding to the second flat Reidemeister move.
Based on the normalized homology, we define cocycle invariants.
