public boolean isValid() {
		boolean result = true;
		
		if (rules==null) {
			System.out.println("=== UNEXPECTED SITUIATION:"+this);
			return false;
		}
		int rule = rules.get(0);
		if (rule>0) {
			int pos = findRule(rule,0);
			if (pos<0) {
				return false;
			} else {
				int newPos = pos+rule+1;
				for (int i=1; i<rules.size(); i++) {
					rule = rules.get(i);
					if (rule==0) break;
					pos = findRule(rule,newPos);
					if (pos<0) {
						return false;
					} 
					newPos=pos+rule+1;
				}
			}
		}
		return result;
	}