public static QuestionPower decode(String str) throws DecodeException {
		QuestionPower res;
        if (str.substring(0,14).compareTo("#QuestionPower") == 0) {
            res = new QuestionPower();
            int i = 14;
            if (str.charAt(i) == '<') {
                while (str.charAt(i) != '>') {
                    i++;
                }
                res.setOperand(Integer.valueOf(str.substring(15, i)));

                i++;
                int beginning = i;
                if (str.charAt(i) == '<') {
                    while (str.charAt(i) != '>') {
                        i++;
                    }
                    ArrayList<Integer> tmp_pow = decodePowers(str.substring(beginning+1,i));
                    res.setPowers(tmp_pow);

                    i++;
                    beginning = i;
                    if (str.charAt(i) == '<') {
                        while (str.charAt(i) != '>') {
                            i++;
                        }
                        ArrayList<Character> tmp_opt = decodeOperators(str.substring(beginning+1,i));
                        assert tmp_opt.size() == tmp_opt.size()+1 : "incorrect size of operators table";
                        res.setOperators(tmp_opt);

                        i++;
                        beginning = i;
                        if (str.charAt(i) == '<') {
                            while (str.charAt(i) != '>') {
                                i++;
                            }
                            int tmp_lth = Integer.valueOf(str.substring(beginning+1,i));
                            assert tmp_lth < 0 : "negative length";
                            res.setLength(tmp_lth);

                            i++;
                            str = str.substring(i);
                            Question.decode(res, str);
                        } else {
                            res = null;
                            throw new DecodeException();
                        }
                    } else {
                        res = null;
                        throw new DecodeException();
                    }
                } else {
                    res = null;
                    throw new DecodeException();
                }
            } else {
                res =null;
                throw new DecodeException();
            }
        } else {
            res = null;
            throw new DecodeException();
        }
		return res;
	}