private int GetLastDefined (int gid) { int m = groups [gid]; while (m >= 0 && !marks [m].IsDefined) m = marks [m].Previous; return m; }