package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"runtime"
	"sort"
)

type env struct {
	w, h, i int
	fits, holds map[*env]bool
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return len(slice[i].holds) < len(slice[j].holds);
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0, make(map[*env]bool), make(map[*env]bool)}
	all := make(map[*env]bool)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1, make(map[*env]bool), make(map[*env]bool)}
		if !card.ft(e) {
			continue
		}
		all[e] = true
	}
	runtime.GC()
	for e := range all {
		temp := make(map[*env]bool)
		for t := range all {
			temp[t] = true
		}
		for t := range temp {
			if e == t {
				continue
			}
			if e.ft(t) {
				t.holds[e] = true
				e.fits[t] = true
				for r := range e.fits {
					delete(temp, r)
					e.fits[r] = true
					r.holds[e] = true
				}
			}
		}
		runtime.GC()
	}
	var best *env = nil
	for e := range all {
		if best == nil || len(best.holds) < len(e.holds) {
			best = e
		}
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	runtime.GC()
	res := make(envs, 0)
	res = append(res, best)
	for e := range best.holds {
		res = append(res, e)
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	sort.Sort(res)
	s := fmt.Sprintf("%v", res)
	printf("%d\n%s\n", len(res), s[1:len(s)-1])
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"runtime"
	"sort"
)

type env struct {
	w, h, i int
	fits, holds map[*env]bool
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return len(slice[i].holds) < len(slice[j].holds);
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0, make(map[*env]bool), make(map[*env]bool)}
	all := make(map[*env]bool)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1, make(map[*env]bool), make(map[*env]bool)}
		if !card.ft(e) {
			continue
		}
		all[e] = true
	}
	runtime.GC()
	for e := range all {
		temp := make(map[*env]bool)
		for t := range all {
			temp[t] = true
		}
		for t := range temp {
			if e == t {
				continue
			}
			if e.ft(t) {
				t.holds[e] = true
				e.fits[t] = true
				for r := range e.fits {
					delete(temp, r)
					e.fits[r] = true
					r.holds[e] = true
				}
			}
		}
		runtime.GC()
	}
	var best *env = nil
	for e := range all {
		if best == nil || len(best.holds) < len(e.holds) {
			best = e
		}
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	if best == nil {
		printf("0\n")
		return
	}
	runtime.GC()
	res := make(envs, 0)
	res = append(res, best)
	for e := range best.holds {
		res = append(res, e)
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	sort.Sort(res)
	last := card
	res2 := make(envs, 0)
	for i, x := range res {
		if last.ft(x) {
			res2 = append(res2, x)
			last = x
		}
		if i % 100 == 0 {
			runtime.GC()
		}
	}
	s := fmt.Sprintf("%v", res2)
	printf("%d\n%s\n", len(res2), s[1:len(s)-1])
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"runtime"
	"sort"
)

type env struct {
	w, h, i int
	fits, holds map[*env]bool
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return len(slice[i].holds) < len(slice[j].holds);
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0, make(map[*env]bool), make(map[*env]bool)}
	all := make(map[*env]bool)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1, make(map[*env]bool), make(map[*env]bool)}
		if !card.ft(e) {
			continue
		}
		all[e] = true
	}
	runtime.GC()
	for e := range all {
		temp := make(map[*env]bool)
		for t := range all {
			temp[t] = true
		}
		for t := range temp {
			if e == t {
				continue
			}
			if e.ft(t) {
				t.holds[e] = true
				e.fits[t] = true
				for r := range e.fits {
					delete(temp, r)
					e.fits[r] = true
					r.holds[e] = true
				}
			}
		}
		runtime.GC()
	}
	var best *env = nil
	for e := range all {
		if best == nil || len(best.holds) < len(e.holds) {
			best = e
		}
		if e.i % 1000 == 0 {
			runtime.GC()
		}
	}
	if best == nil {
		printf("0\n")
		return
	}
	runtime.GC()
	res := make(envs, 0)
	res = append(res, best)
	for e := range best.holds {
		res = append(res, e)
		if e.i % 1000 == 0 {
			runtime.GC()
		}
	}
	sort.Sort(res)
	last := card
	res2 := make(envs, 0)
	for i, x := range res {
		if last.ft(x) {
			res2 = append(res2, x)
			last = x
		}
		if i % 1000 == 0 {
			runtime.GC()
		}
	}
	s := fmt.Sprintf("%v", res2)
	printf("%d\n%s\n", len(res2), s[1:len(s)-1])
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"sort"
	"runtime"
)

type env struct {
	w, h, i int
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return float64(slice[i].w) * float64(slice[i].h) < float64(slice[j].w) * float64(slice[j].h)
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0}
	all := make(envs, 0)
	all = append(all, card)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1}
		if card.ft(e) {
			all = append(all, e)
		}
	}
	sort.Sort(all)
	runtime.GC()
	d := make([]int, len(all))
	p := make([]int, len(all))
	m, ps := 0, 0
	for i := 0; i < len(d); i++ {
		d[i] = 1
		p[i] = -1
		for j := 0; j < i; j++ {
			if all[j].ft(all[i]) {
				if d[i] < d[j] + 1 {
					d[i] = d[j] + 1
					p[i] = j
				}
				if d[i] > m {
					m = d[i]
					ps = i
				}
			}
		}
	}
	path := make([]int, 0)
	for ps != -1 {
		path = append([]int{all[ps].i}, path...)
		ps = p[ps]
	}
	path = path[1:]
	printf("%d\n", len(path))
	if len(path) > 0 {
		s := fmt.Sprintf("%v", path)
		printf("%s\n", s[1:len(s)-1])
	}

}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"runtime"
	"sort"
)

type env struct {
	w, h, i int
	fits, holds map[*env]bool
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return len(slice[i].holds) < len(slice[j].holds);
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0, make(map[*env]bool), make(map[*env]bool)}
	all := make(map[*env]bool)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1, make(map[*env]bool), make(map[*env]bool)}
		if !card.ft(e) {
			continue
		}
		all[e] = true
	}
	runtime.GC()
	for e := range all {
		temp := make(map[*env]bool)
		for t := range all {
			temp[t] = true
		}
		for t := range temp {
			if e == t {
				continue
			}
			if e.ft(t) {
				t.holds[e] = true
				e.fits[t] = true
				for r := range e.fits {
					delete(temp, r)
					e.fits[r] = true
					r.holds[e] = true
				}
			}
		}
		runtime.GC()
	}
	var best *env = nil
	for e := range all {
		if best == nil || len(best.holds) < len(e.holds) {
			best = e
		}
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	if best == nil {
		printf("0\n")
		return
	}
	runtime.GC()
	res := make(envs, 0)
	res = append(res, best)
	for e := range best.holds {
		res = append(res, e)
		if e.i % 100 == 0 {
			runtime.GC()
		}
	}
	sort.Sort(res)
	s := fmt.Sprintf("%v", res)
	printf("%d\n%s\n", len(res), s[1:len(s)-1])
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"sort"
	"runtime"
)

type env struct {
	w, h, i int
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return slice[i].ft(slice[j])
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0}
	all := make(envs, 0)
	all = append(all, card)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1}
		if card.ft(e) {
			all = append(all, e)
		}
	}
	sort.Sort(all)
	runtime.GC()
	d := make([]int, len(all))
	p := make([]int, len(all))
	m, ps := 0, 0
	for i := 0; i < len(d); i++ {
		d[i] = 1
		p[i] = -1
		for j := 0; j < i; j++ {
			if all[j].ft(all[i]) {
				if d[i] < d[j] + 1 {
					d[i] = d[j] + 1
					p[i] = j
				}
				if d[i] > m {
					m = d[i]
					ps = i
				}
			}
		}
	}
	path := make([]int, 0)
	for ps != -1 {
		path = append([]int{all[ps].i}, path...)
		ps = p[ps]
	}
	path = path[1:]
	printf("%d\n", len(path))
	if len(path) > 0 {
		s := fmt.Sprintf("%v", path)
		printf("%s\n", s[1:len(s)-1])
	}

}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
	"errors"
	"sort"
	"runtime"
)

type env struct {
	w, h, i int
}

func (e *env) ft(ee *env) bool {
	return e.w < ee.w && e.h < ee.h
}

func (e *env) String() string {
	return strconv.Itoa(e.i)
}

type envs []*env

func (slice envs) Len() int {
	return len(slice)
}

func (slice envs) Less(i, j int) bool {
	return slice[i].w * slice[i].h < slice[j].w * slice[j].h
}

func (slice envs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	n, w, h := nextInt(), nextInt(), nextInt()
	card := &env{w, h, 0}
	all := make(envs, 0)
	all = append(all, card)
	for i := 0; i < n; i++ {
		ew, eh := nextInt(), nextInt()
		e := &env{ew, eh, i + 1}
		if card.ft(e) {
			all = append(all, e)
		}
	}
	sort.Sort(all)
	runtime.GC()
	d := make([]int, len(all))
	p := make([]int, len(all))
	m, ps := 0, 0
	for i := 0; i < len(d); i++ {
		d[i] = 1
		p[i] = -1
		for j := 0; j < i; j++ {
			if all[j].ft(all[i]) {
				if d[i] < d[j] + 1 {
					d[i] = d[j] + 1
					p[i] = j
				}
				if d[i] > m {
					m = d[i]
					ps = i
				}
			}
		}
	}
	path := make([]int, 0)
	for ps != -1 {
		path = append([]int{all[ps].i}, path...)
		ps = p[ps]
	}
	path = path[1:]
	printf("%d\n", len(path))
	if len(path) > 0 {
		s := fmt.Sprintf("%v", path)
		printf("%s\n", s[1:len(s)-1])
	}

}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


//  URL: http://codeforces.com/contest/4/problem/D
//  PROBLEM RESTATEMENT
//      Let A be a set of envelopes, each envelope contains integer height and width.
//      Chain C is a subset of A, where C[i] height and width > C[i-1] height
//      and width.
//      Find the chain of maximum size.
//  CONSTRAINTS
//      1 <= n <= 5000, 1 <= w, h <= 10^6
//  APPROACH
//      (1) Discard all envelopes that Peter's card cannot fit into.
//      (2) Sort and call the remaining envelopes set E.
//      (3) At any given step, we need to find the minimum envelope that has
//          height and width greater than the current element.
//      (4) In O(n^2), we can compute the maximum chain length using DP:
//            * Initialize each element of dp with 1.
//            * dp[i] = max(dp[i-1], dp[i-2] ... dp[0]) + 1

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Envelope struct {
	Width  int
	Height int
	Child  int
	Number int
}

func solve(dp []int, e []Envelope) []int {
	// Solve the DP recurrence.
	for i := 1; i < len(dp); i++ {
		for j := 0; j < i; j++ {
			if e[i].Width > e[j].Width && e[i].Height > e[j].Height {
				if dp[j]+1 > dp[i] {
					dp[i] = dp[j] + 1
					e[i].Child = j
				}
			}
		}
	}
	// Find max element of DP - the length and final index of the chain.
	maxChainIndex := 0
	maxChainLength := 0
	for i := 0; i < len(dp); i++ {
		if dp[i] > maxChainLength {
			maxChainLength = dp[i]
			maxChainIndex = i
		}
	}
	if maxChainLength == 0 {
		return []int{}
	}
	// Follow the children to find the envelopes in the largest chain.
	var ans []int
	for maxChainIndex != -1 {
		ans = append(ans, e[maxChainIndex].Number)
		maxChainIndex = e[maxChainIndex].Child
	}
	return ans
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n, w, h int
	fmt.Fscanf(reader, "%d %d %d\n", &n, &w, &h)
	var dp []int
	var e []Envelope
	for i := 0; i < n; i++ {
		var wi, hi int
		fmt.Fscanf(reader, "%d %d\n", &wi, &hi)
		if wi > w && hi > h {
			e = append(e, Envelope{wi, hi, -1, i + 1})
			dp = append(dp, 1)
		}
	}
	sort.Slice(e, func(i, j int) bool {
		if e[i].Width < e[j].Width {
			return true
		} else if e[i].Height < e[j].Height {
			return true
		}
		return false
	})
	solution := solve(dp, e)
	l := len(solution)
	if l == 0 {
		fmt.Fprintf(writer, "%d\n", 0)
	} else {
		fmt.Fprintf(writer, "%d\n", l)
		for i := l - 1; i >= 0; i-- {
			fmt.Fprintf(writer, "%d ", solution[i])
		}
		fmt.Fprintf(writer, "\n")
	}
}


//  URL: http://codeforces.com/contest/4/problem/D
//  PROBLEM RESTATEMENT
//      Let A be a set of envelopes, each envelope contains integer height and width.
//      Chain C is a subset of A, where C[i] height and width > C[i-1] height
//      and width.
//      Find the chain of maximum size.
//  CONSTRAINTS
//      1 <= n <= 5000, 1 <= w, h <= 10^6
//  APPROACH
//      (1) Discard all envelopes that Peter's card cannot fit into.
//      (2) Sort and call the remaining envelopes set E.
//      (3) At any given step, we need to find the minimum envelope that has
//          height and width greater than the current element.
//      (4) In O(n^2), we can compute the maximum chain length using DP:
//            * Initialize each element of dp with 1.
//            * dp[i] = max(dp[i-1], dp[i-2] ... dp[0]) + 1

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Envelope struct {
	Width  int
	Height int
	Child  int
	Number int
}

func solve(dp []int, e []Envelope) []int {
	// Solve the DP recurrence.
	for i := 1; i < len(dp); i++ {
		for j := 0; j < i; j++ {
			if e[i].Width > e[j].Width && e[i].Height > e[j].Height {
				if dp[j]+1 > dp[i] {
					dp[i] = dp[j] + 1
					e[i].Child = j
				}
			}
		}
	}
	// Find max element of DP - the length and final index of the chain.
	maxChainIndex := 0
	maxChainLength := 0
	for i := 0; i < len(dp); i++ {
		if dp[i] > maxChainLength {
			maxChainLength = dp[i]
			maxChainIndex = i
		}
	}
	if maxChainLength == 0 {
		return []int{}
	}
	// Follow the children to find the envelopes in the largest chain.
	var ans []int
	for maxChainIndex != -1 {
		ans = append(ans, e[maxChainIndex].Number)
		maxChainIndex = e[maxChainIndex].Child
	}
	return ans
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n, w, h int
	fmt.Fscanf(reader, "%d %d %d\n", &n, &w, &h)
	var dp []int
	var e []Envelope
	for i := 0; i < n; i++ {
		var wi, hi int
		fmt.Fscanf(reader, "%d %d\n", &wi, &hi)
		if wi > w && hi > h {
			e = append(e, Envelope{wi, hi, -1, i + 1})
			dp = append(dp, 1)
		}
	}
	sort.Slice(e, func(i, j int) bool {
		return e[i].Width < e[j].Width
	})
	solution := solve(dp, e)
	l := len(solution)
	if l == 0 {
		fmt.Fprintf(writer, "%d\n", 0)
	} else {
		fmt.Fprintf(writer, "%d\n", l)
		for i := l - 1; i >= 0; i-- {
			fmt.Fprintf(writer, "%d ", solution[i])
		}
		fmt.Fprintf(writer, "\n")
	}
}


// problem_d
package main

import (
	"fmt"
	"sort"
)

type Letter struct {
	x   int
	y   int
	num int
	res int
	p   int
}

type ByLetter []Letter

func (a ByLetter) Len() int      { return len(a) }
func (a ByLetter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByLetter) Less(i, j int) bool {
	if a[i].x != a[j].x {
		return a[i].x < a[j].x
	}
	if a[i].y != a[j].y {
		return a[i].y < a[j].y
	}
	return a[i].num < a[j].num
}

func main() {
	var n, w, h int
	var lts ByLetter
	fmt.Scan(&n, &w, &h)
	//	fmt.Println(p1, p2, n)
	var w1, h1 int
	for i := 0; i < n; i++ {
		fmt.Scan(&w1, &h1)
		//		fmt.Println(w1, h1)
		if w1 > w && h1 > h {
			lts = append(lts, Letter{w1, h1, i, 1, -1})
		}
	}
	sort.Sort(lts)
	//	fmt.Println(lts)
	nn := lts.Len()
	if nn == 0 {
		fmt.Println("0")
		return
	}
	for i := 1; i < nn; i++ {
		for j := 0; j < i; j++ {
			if lts[j].x < lts[i].x && lts[j].y < lts[i].y &&
				lts[j].res >= lts[i].res {
				lts[i].res = lts[j].res + 1
				lts[i].p = j
			}
		}
	}
	max := 0
	mi := 0
	for i := 0; i < nn; i++ {
		if max < lts[i].res {
			max = lts[i].res
			mi = i
		}
	}
	//	fmt.Println(lts)
	fmt.Println(max)
	var ans []int
	for mi != -1 {
		ans = append(ans, lts[mi].num+1)
		mi = lts[mi].p
	}
	ans_len := len(ans)
	for i := ans_len - 1; i >= 0; i-- {
		fmt.Print(ans[i], " ")
	}
}


db = dict()
re = input()
for ri in xrange(re):
	name = raw_input()
	num = db.get(name, 0)
	if num:
		print name + str(num)
	else:
		print 'OK'
	db[name] = num + 1

'''

'''


<?php

class Envelope {
	public $w, $h, $i, $p;
	public function __construct($w, $h, $i) {
		$this->w = $w;
		$this->h = $h;
		$this->i = $i;
		$this->p = NULL;
	}
}

function cmp($a, $b) {
	if ($a->w != $b->w) {
		return $a->w < $b->w ? -1 : 1;
	} else if ($a->h != $b->h) {
		return $a->h > $b->h ? -1 : 1;
	} else {
		return 0;
	}
}

fscanf(STDIN, "%d%d%d", $n, $w, $h);
$a = Array();
for ($i = 1; $i <= $n; ++$i) {
	fscanf(STDIN, "%d%d", $wi, $hi);
	if ($wi > $w && $hi > $h) {
		array_push($a, new Envelope($wi, $hi, $i));
	}
}

usort($a, 'cmp');
$b = Array();
foreach ($a as $ai) {
	$l = 0;
	$r = count($b);
	while ($l < $r) {
		$m = ($l + $r) / 2;
		if ($ai->h > $b[$m]->h) {
			$l = $m + 1;
		} else {
			$r = $m;
		}
	}
	$ai->p = ($r == 0 ? NULL : $b[$r - 1]);
	$b[$r] = $ai;
}

echo count($b) . "\n";
if (count($b) > 0) {
	$c = Array();
	for ($p = array_pop($b); $p != NULL; $p = $p->p) {
		array_unshift($c, $p->i);
	}
	print implode($c, ' ') . "\n";
}

/*

*/


n, w, h = map(int, raw_input().split())
dims = []
for i in range(n):
	dims.append(map(int, raw_input().split()) + [i])
dims.sort()
dp = [0 for i in range(n)]
bck = [i for i in range(n)]
for i in range(n):
	if dims[i][0] > w and dims[i][1] > h:
		mx = 0
		mxj = i
		for j in range(i-1, -1, -1):
			if dp[j] > mx and dims[j][0] < dims[i][0] and dims[j][1] < dims[i][1]:
				mx = dp[j]
				mxj = j
		dp[i] = mx + 1
		bck[i] = mxj

ans = []
idx = dp.index(max(dp))
while idx != bck[idx]:
	ans.append(dims[idx][2] + 1)
	idx = bck[idx]
ans.append(dims[idx][2] + 1)

if max(dp) == 0:
	print 0
else:
	print max(dp)
	for i in reversed(ans):
		print i,


n,w1,h1=map(int,raw_input().split())
ans=[]
class var:
  w=0
  h=0
for _ in range(0,n):
  w,h=map(int,raw_input().split())
  ans.append((w,h))
ans2=[]
#print ans
ans3=[-1]*(n+2)
for i in range(0,len(ans)):
  vl=ans[i]
  if vl[0]>w1 and vl[1]>h1:
    ans2.append((ans[i][0],ans[i][1],i))
ans2.sort()
dp=[1]*(n)
ans=[]
t=0
ans5=[]
n=len(ans2)
for i in range(1,n):
  for j in range(0,i):
    if ans2[j][0]<ans2[i][0] and ans2[j][1]<ans2[i][1] and dp[i]<dp[j]+1:
      dp[i]=dp[j]+1
      ans3[i]=j
      t=i

ans4=[]
fvv=[]
if len(ans2)==0:
  print 0
else:

  while t!=-1:
    fvv.append(ans2[t][2])
    #ans4.append(t)
    t=ans3[t]
  fvv.reverse()
  print len(fvv)
  for i in fvv:
    print i+1,
  print


n,w1,h1=map(int,raw_input().split())
ans=[]
class var:
  w=0
  h=0
for _ in range(0,n):
  w,h=map(int,raw_input().split())
  ans.append((w,h))
ans2=[]
#print ans
ans3=[-1]*(n+2)
for i in range(0,len(ans)):
  vl=ans[i]
  if vl[0]>w1 and vl[1]>h1:
    ans2.append((ans[i][0],ans[i][1],i))
ans2.sort()
dp=[1]*(n)
ans=[]
t=0
ans5=[]
n=len(ans2)
for i in range(1,n):
  for j in range(0,i):
    if ans2[j][0]<ans2[i][0] and ans2[j][1]<ans2[i][1] and dp[i]<dp[j]+1:
      dp[i]=dp[j]+1
      ans3[i]=j
      t=i

ans4=[]
fvv=[]
while t!=-1:
  fvv.append(ans2[t][2])
  #ans4.append(t)
  t=ans3[t]
fvv.reverse()
print len(fvv)
for i in fvv:
  print i+1,
print


n,w1,h1=map(int,raw_input().split())
ans=[]
class var:
  w=0
  h=0
for _ in range(0,n):
  w,h=map(int,raw_input().split())
  ans.append((w,h))
ans2=[]
#print ans
ans3=[-1]*(n+2)
for i in range(0,len(ans)):
  vl=ans[i]
  if vl[0]>w1 and vl[1]>h1:
    ans2.append((ans[i][0],ans[i][1],i))
ans2.sort()
dp=[1]*(n)
ans=[]
t=0
ans5=[]
n=len(ans2)
for i in range(1,n):
  for j in range(0,i):
    if ans2[j][0]<ans2[i][0] and ans2[j][1]<ans2[i][1] and dp[i]<dp[j]+1:
      dp[i]=dp[j]+1
      ans3[i]=j
      t=i

ans4=[]
fvv=[]
m=-100
for i in range(0,n):
  if dp[i]>m:
    t=i
    m=dp[i]

#print ans2,ans3,dp
if len(ans2)==0:
  print 0
else:

  while t!=-1:
    fvv.append(ans2[t][2])
    #ans4.append(t)
    t=ans3[t]
  fvv.reverse()
  print len(fvv)
  for i in fvv:
    print i+1,
  print


from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write

def in_num():
    return int(raw_input())

def in_arr():
    return map(int,raw_input().split())

def pr_num(n):
    stdout.write(str(n)+'\n')

def pr_arr(arr):
    pr(' '.join(map(str,arr))+'\n')

# fast read function for total integer input

def inp():
    # this function returns whole input of
    # space/line seperated integers
    # Use Ctrl+D to flush stdin.
    return map(int,stdin.read().split())

range = xrange # not for python 3.0+

n,w,h=in_arr()
arr=[]
for i in range(n):
    arr.append(in_arr()+[i+1])
arr.sort()
dp=[1]*n
d=[[arr[i][-1]] for i in range(n)]
for i in range(n-2,-1,-1):
    val=[]
    for j in range(i+1,n):
        if arr[i][0]<arr[j][0] and arr[i][1]<arr[j][1]:
            if dp[i]<dp[j]+1:

                dp[i]=dp[j]+1
                val=d[j]
    d[i]+=val
ans=0
ind=-1
for i in range(n):
    if arr[i][0]>w and arr[i][1]>h and dp[i]>ans:
        ans=dp[i]
        ind=i
pr_num(ans)
if ans:
    pr_arr(d[ind])


#from bisect import bisect_right
n,w,h=map(int,raw_input().split())
a=[]
for i in range(n):
    x=map(int,raw_input().split())
    if x[0]>w and x[1]>h:
        x.append(i+1)
        a.append(x)
a.sort()
dp=[1]*(n)
#k=bisect_right(a,[w,h])
#if k<n and (a[k][0]<=w or a[k][1]<=h):
#    k+=1
#a=a[k:]
#print k
l=len(a)
dp=[1]*(l)
if l==0:
    print 0
else:
    for i in range(1,l):
        for j in range(i):
            if a[i][0]>a[j][0] and a[i][1]>a[j][1]:
                dp[i]=max(dp[i],dp[j]+1)
    m=max(dp)
    i=dp.index(m)
    print m
    ans=[a[i][2]]
    k=i
    m-=1
    #print a,dp
    for j in range(i-1,-1,-1):
        if dp[j]==m and a[j][0]<a[k][0] and a[j][1]<a[k][1]:
            ans.append(a[j][2])
            m-=1
            k=j
        if m==0:
            break
    #print ans
    for i in ans[::-1]:
        print i,


def inside(a, b):
    return a[0] < b[0] and a[1] < b[1]

n, w, h = map(int, raw_input().split())
c = []
for i in xrange(n):
    a, b = map(int, raw_input().split())
    if a > w and b > h:
        c.append((a, b, i + 1))

if not c:
    print(0)
    import sys
    sys.exit(0)

c.sort()
n = len(c)
dp = [1] * n
pr = [-1] * n
mx_i = 0
for i in range(n):
    j =0
    while j < i:
        if inside(c[j], c[i]) and dp[j] + 1 > dp[i]:
            dp[i] = dp[j] + 1
            pr[i] = j
            if (dp[i] > dp[mx_i]):
                mx_i = i
        j += 1

res = []
while mx_i != -1:
    res.append(c[mx_i][2])
    mx_i = pr[mx_i]

print(len(res))
print(" ".join(map(str, res[::-1])))


def inside(a, b):
    return a[0] < b[0] and a[1] < b[1]

input = raw_input

n, w, h = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    if a > w and b > h:
        c.append((a, b, i + 1))

if not c:
    print(0)
    import sys
    sys.exit(0)

c.sort()
n = len(c)
dp = [1] * n
pr = [-1] * n
mx_i = 0
for i in range(n):
    j = i - 1
    while j >= 0:
        if inside(c[j], c[i]) and dp[j] + 1 > dp[i]:
            dp[i] = dp[j] + 1
            pr[i] = j
            if (dp[i] > dp[mx_i]):
                mx_i = i
        j -= 1

res = []
while mx_i != -1:
    res.append(c[mx_i][2])
    mx_i = pr[mx_i]

print(len(res))
print(" ".join(map(str, res[::-1])))


n,w,h=map(int,raw_input().split())
en=[]
arar=[]
ar={}
co={}
for i in xrange(n):
    x,y=map(int,raw_input().split())
    co[(x,y)]=i+1
    area=x*y
    en.append((x,y))
    arar.append(area)
    if area not in ar:
        ar[area]=[(x,y)]
    else:
        ar[area].append((x,y))
arar=set(arar)
arar=list(arar)
arar.sort()
#arar=set(arar)
#print arar
#print ar
def points_choosen(a,l):
    choosen=[0,0]
    marginX=10000000
    marginY=10000000
    margindist=100000000
    for i in l:
        if a[0]>i[0] and a[1]>i[1]:
            margineX=(a[0]-i[0])
            margineY=(a[1]-i[1])
            if (margineX<marginX and margineY<marginY) or((a[0]-i[0])**2+(a[1]-i[1]**2)<margindist):
                choosen=[i[0],i[1]]
    return  choosen
ans=[(n,w)]
for i in arar:
    if i>=w*h:
       ans+=ar[i]
#print ans
bips=len(ans)
i=0
while i<len(ans):
    #print ans[i]
    if ans[i][0]>w and ans[i][1]>h:
        #ans.pop(i)
        #pass
        i+=1
    else:
        ans.pop(i)
ans=[(w,h)]+ans
#print ans
dp=[0]*len(ans)
m=-10000
mn=-100000
for i in xrange(1,len(ans)):
    #lit=[]
    for j in xrange(i):
        if ans[i][0]>ans[j][0] and ans[i][1]>ans[j][1]:
            if dp[i]<dp[j]+1:
                dp[i]=dp[j]+1

            if mn<=dp[i] :
                m=i
                mn=dp[i]
ansarray=[m]
print mn
piu=m
for i in xrange(m-1,0,-1):
    if ans[i][0]<ans[piu][0] and ans[i][1]<ans[piu][1]:
        ansarray.append(i)
        piu=i

#print ans,len(ans)
#print dp
to=ansarray[::-1]
finalan=[]
#print to
#print m
for i in xrange(len(to)):
    finalan.append(co[ans[to[i]]])
for i in  finalan:
    print i,


splitted = [int(amit) for amit in raw_input().split(" ")]
n = splitted[0]
w = splitted[1]
h = splitted[2]
cards = list()
origIndices = dict()
for i in range(n):
	splitted = [int(amit) for amit in raw_input().split(" ")]
	cards.append((splitted[0] * splitted[1], splitted[0], splitted[1]))
	origIndices[(splitted[0], splitted[1])] = i
cards.sort()
dp = [(0, 0, 0)] * (n + 1)
inSequence = dict()
for i in range(n):
	card = cards[i]
	cardWidth = card[1]
	cardHeight = card[2]
	if w < cardWidth and h < cardHeight:
		maxResWhereFits = 0
		for j in range(i):
			prevCard = cards[j]
			prevWidth = prevCard[1]
			prevHeight = prevCard[2]
			if prevWidth < cardWidth and prevHeight < cardHeight:
				maxResWhereFits = dp[j][0]

		toBeInSequence = list()
		if i - 1 in inSequence:
			toBeInSequence = list(inSequence[i - 1])
		toBeInSequence.append(origIndices[(cardWidth, cardHeight)] + 1)
		inSequence[i] = toBeInSequence
		dp[i] = (maxResWhereFits + 1, cardWidth, cardHeight)

maxRes = 0
sequence = list()
for i in range(len(dp)):
	tup = dp[i]
	curRes = tup[0]
	if curRes > maxRes:
		sequence = inSequence[i]
		maxRes = curRes
print (maxRes)
stringres = ""
for item in sequence:
	stringres += str(item) + " "

print (stringres)


splitted = [int(amit) for amit in raw_input().split(" ")]
n = splitted[0]
w = splitted[1]
h = splitted[2]
cards = list()
origIndices = dict()
for i in range(n):
	splitted = [int(amit) for amit in raw_input().split(" ")]
	cards.append((splitted[0] * splitted[1], splitted[0], splitted[1]))
	origIndices[(splitted[0], splitted[1])] = i
cards.sort()
dp = [(0, 0, 0)] * (n + 1)
inSequence = dict()
for i in range(n):
	card = cards[i]
	cardWidth = card[1]
	cardHeight = card[2]
	if w < cardWidth and h < cardHeight:
		maxResWhereFits = 0
		maxResWhereFitsIndex = 0
		for j in range(i):
			prevCard = cards[j]
			prevWidth = prevCard[1]
			prevHeight = prevCard[2]
			if prevWidth < cardWidth and prevHeight < cardHeight and maxResWhereFits <= dp[j][0]:
				maxResWhereFits = dp[j][0]
				maxResWhereFitsIndex = j

		toBeInSequence = list()
		if maxResWhereFitsIndex in inSequence:
			toBeInSequence = list(inSequence[maxResWhereFitsIndex])

		toBeInSequence.append(origIndices[(cardWidth, cardHeight)] + 1)

		inSequence[i] = toBeInSequence
		dp[i] = (maxResWhereFits + 1, cardWidth, cardHeight)

maxRes = 0
sequence = list()
for i in range(len(dp)):
	tup = dp[i]
	curRes = tup[0]
	if curRes > maxRes:
		sequence = inSequence[i]
		maxRes = curRes
print (maxRes)
stringres = ""
for item in sequence:
	stringres += str(item) + " "

print (stringres)


splitted = [int(amit) for amit in raw_input().split(" ")]
n = splitted[0]
w = splitted[1]
h = splitted[2]
cards = list()
origIndices = dict()
for i in range(n):
	splitted = [int(amit) for amit in raw_input().split(" ")]
	cards.append((splitted[0] * splitted[1], splitted[0], splitted[1]))
	origIndices[(splitted[0], splitted[1])] = i
#cards.sort()
dp = [(0, 0, 0)] * (n + 1)
inSequence = dict()
for i in range(n):
	card = cards[i]
	cardWidth = card[1]
	cardHeight = card[2]
	if w < cardWidth and h < cardHeight:
		maxResWhereFits = 0
		maxResWhereFitsIndex = 0
		for j in range(i):
			prevCard = cards[j]
			prevWidth = prevCard[1]
			prevHeight = prevCard[2]
			if prevWidth < cardWidth and prevHeight < cardHeight and maxResWhereFits <= dp[j][0]:
				maxResWhereFits = dp[j][0]
				maxResWhereFitsIndex = j

		toBeInSequence = list()
		if maxResWhereFitsIndex in inSequence:
			toBeInSequence = list(inSequence[maxResWhereFitsIndex])

		toBeInSequence.append(origIndices[(cardWidth, cardHeight)] + 1)

		inSequence[i] = toBeInSequence
		dp[i] = (maxResWhereFits + 1, cardWidth, cardHeight)

maxRes = 0
sequence = list()
for i in range(len(dp)):
	tup = dp[i]
	curRes = tup[0]
	if curRes > maxRes:
		sequence = inSequence[i]
		maxRes = curRes
print (maxRes)
stringres = ""
for item in sequence:
	stringres += str(item) + " "

print (stringres)


splitted = [int(amit) for amit in raw_input().split(" ")]
n = splitted[0]
w = splitted[1]
h = splitted[2]
cards = list()
origIndices = dict()
for i in range(n):
	splitted = [int(amit) for amit in raw_input().split(" ")]
	cards.append((splitted[0] * splitted[1], splitted[0], splitted[1]))
	origIndices[(splitted[0], splitted[1])] = i
cards.sort()
dp = [(0, 0, 0)] * (n + 1)
inSequence = dict()
for i in range(n):
	card = cards[i]
	cardWidth = card[1]
	cardHeight = card[2]
	if w < cardWidth and h < cardHeight:
		maxResWhereFits = 0
		maxResWhereFitsIndex = 0
		for j in range(i):
			prevCard = cards[j]
			prevWidth = prevCard[1]
			prevHeight = prevCard[2]
			if prevWidth < cardWidth and prevHeight < cardHeight and maxResWhereFits <= dp[j][0]:
				maxResWhereFits = dp[j][0]
				maxResWhereFitsIndex = j
				if True:
					fakeVar = 1

		toBeInSequence = list()
		if maxResWhereFitsIndex in inSequence:
			toBeInSequence = list(inSequence[maxResWhereFitsIndex])

		toBeInSequence.append(origIndices[(cardWidth, cardHeight)] + 1)

		inSequence[i] = toBeInSequence
		dp[i] = (maxResWhereFits + 1, cardWidth, cardHeight)

maxRes = 0
sequence = list()
for i in range(len(dp)):
	tup = dp[i]
	curRes = tup[0]
	if curRes > maxRes:
		sequence = inSequence[i]
		maxRes = curRes
print (maxRes)
stringres = ""
for item in sequence:
	stringres += str(item) + " "

print (stringres)


def inside(a, b):
    return a[0] < b[0] and a[1] < b[1]

input = raw_input

n, w, h = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    if a > w and b > h:
        c.append((a, b, i + 1))

c.sort()
n = len(c)
dp = [1] * n
pr = [-1] * n
mx_i = 0
for i in range(n):
    j = i - 1
    while j >= 0:
        if inside(c[j], c[i]) and dp[j] + 1 > dp[i]:
            dp[i] = dp[j] + 1
            pr[i] = j
            if (dp[i] > dp[mx_i]):
                mx_i = i
        j -= 1

res = []
while mx_i != -1:
    res.append(c[mx_i][2])
    mx_i = pr[mx_i]

print(len(res))
print(" ".join(map(str, res[::-1])))


# sort by w in ascending order
# dp[i] = max(dp[j:0,i-1] + h[i] > h[j] ? 1 : 0);
# n^2

import sys

nums = sys.stdin.readline().split()
n = int(nums[0])
wc = int(nums[1])
hc = int(nums[2])

e = []
for i in xrange(0, n):
    nums = sys.stdin.readline().split()
    w = int(nums[0])
    h = int(nums[1])
    if w > wc and h > hc:
        e.append((w, h, i))

if len(e) == 0:
    print 0
    sys.exit(0)

e.sort(key=lambda x: x[1])

result = [1]
base = [-1]
max_result_idx = 0
for i in xrange(1, len(e)):
    best_base = -1;
    for j in xrange(0,i):
        if e[i][0] > e[j][0] and e[i][1] > e[j][1] and (best_base == -1 or result[best_base] < result[j]):
            best_base = j;
    if best_base != -1:
        result.append(1 + result[best_base])
    else:
        result.append(1)

    base.append(best_base)
    if result[i] > result[max_result_idx]:
        max_result_idx = i;

print result[max_result_idx]
chain = []
while max_result_idx != -1:
    chain.append(e[max_result_idx][2]+1)
    max_result_idx = base[max_result_idx]
chain.reverse()
print " ".join(str(x) for x in chain)


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
i = 0
while i<N and size[i][0]<=w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<=h:
        i += 1
    if i>=N:
        print 0
    else:
        dp = [-1]*N
        dp[i] = 1
        r = 1
        p = i
        path = range(N)
        for j in xrange(i+1, N):
            mm = -1
            pp = j
            for x in xrange(j-1, i-1, -1):
                if size[x][0]<size[j][0] and size[x][1]<size[j][1] and dp[x] > mm:
                    mm = dp[x]
                    pp = x
            dp[j] = mm + 1
            path[j] = pp
            if dp[j] > r:
                r = dp[j]
                p = j
        envelops = [size[p][2]]
        while path[p] != p and path[p]>=i:
            path.append(size[path[p]][2])
            p = path[p]
        print r
        print " ".join([str(x) for x in envelops[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
#print size
i = 0
while i<N and size[i][0]<=w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<=h:
        i += 1
    if i>=N:
        print 0
    else:
        #print i
        trace = [0]*N
        for m in xrange(1,N):
            t = m
            for n in xrange(m-1, -1, -1):
                if size[n][0]<size[m][0] and size[n][1]<size[m][1]:
                    t = n
                    break
            trace[m] = t
        dp = [0]*N
        dp[i] = 1
        r = 0
        p = 0
        for j in xrange(i+1, N):
            dp[j] = dp[trace[j]] + 1
            if dp[j] > r:
                r = dp[j]
                p = j
        #print dp
        path = [size[p][2]]
        while trace[p] != p and trace[p]>=i:
            path.append(size[trace[p]][2])
            p = trace[p]
        print r
        print " ".join([str(x) for x in path[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
i = 0
while i<N and size[i][0]<=w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<=h:
        i += 1
    if i>=N:
        print 0
    else:
        dp = [-1]*N
        dp[i] = 1
        r = 1
        p = i
        path = range(N)
        for j in xrange(i+1, N):
            mm = -1
            pp = j
            for x in xrange(j-1, i-1, -1):
                if size[x][0]<size[j][0] and size[x][1]<size[j][1] and dp[x] > mm:
                    mm = dp[x]
                    pp = x
            dp[j] = mm + 1
            path[j] = pp
            if dp[j] > r:
                r = dp[j]
                p = j
        #print size
        #print dp
        #print path
        envelops = [size[p][2]]
        while path[p] != p and path[p]>=i:
            envelops.append(size[path[p]][2])
            p = path[p]
        print r
        print " ".join([str(x) for x in envelops[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
#print size
i = 0
while i<N and size[i][0]<w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<h:
        i += 1
    if i>=N:
        print 0
    else:
        #print i
        trace = [0]*N
        for m in xrange(1,N):
            t = m
            for n in xrange(m-1, -1, -1):
                if size[n][0]<size[m][0] and size[n][1]<size[m][1]:
                    t = n
                    break
            trace[m] = t
        dp = [0]*N
        dp[i] = 1
        r = 0
        p = 0
        for j in xrange(i+1, N):
            dp[j] = dp[trace[j]] + 1
            if dp[j] > r:
                r = dp[j]
                p = j
        #print dp
        path = [size[p][2]]
        while trace[p] != p and trace[p]>=i:
            path.append(size[trace[p]][2])
            p = trace[p]
        print r
        print " ".join([str(x) for x in path[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
i = 0
while i<N and size[i][0]<=w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<=h:
        i += 1
    if i>=N:
        print 0
    else:
        dp = [-1]*N
        dp[i] = 1
        r = 1
        p = i
        path = range(N)
        for j in xrange(i+1, N):
            mm = -1
            pp = j
            for x in xrange(j-1, i-1, -1):
                if w<size[x][0]<size[j][0] and h<size[x][1]<size[j][1] and dp[x] > mm:
                    mm = dp[x]
                    pp = x
            dp[j] = mm + 1
            path[j] = pp
            if dp[j] > r:
                r = dp[j]
                p = j
        #print i
        #print size
        #print dp
        #print path
        envelops = [size[p][2]]
        while path[p] != p and path[p]>=i:
            envelops.append(size[path[p]][2])
            p = path[p]
        print r
        print " ".join([str(x) for x in envelops[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size.sort()
i = 0
while i<N and size[i][0]<w:
    i += 1
if i>=N:
    print 0
else:
    while i<N and size[i][1]<h:
        i += 1
    if i>=N:
        print 0
    else:
        trace = [0]*N
        for m in xrange(1,N):
            t = m
            for n in xrange(m-1, -1, -1):
                if size[n][0]<size[m][0] and size[n][1]<size[m][1]:
                    t = n
                    break
            trace[m] = t
        dp = [0]*N
        dp[i] = 1
        r = 0
        p = 0
        for j in xrange(i+1, N):
            dp[j] = dp[trace[j]] + 1
            if dp[j] > r:
                r = dp[j]
                p = j
        path = [size[p][2]]
        while trace[p] != p:
            path.append(size[trace[p]][2])
            p = trace[p]
        print r
        print " ".join([str(x) for x in path[::-1]])


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size = [x for x in size if x[0]>w and x[1]>h]
size.sort()
N = len(size)
if N > 0:
    dp = [0]*N
    dp[0] = 1
    dp_meta = range(N)
    for i in xrange(1,N):
        dp[i] = 0
        for j in xrange(i-1, -1, -1):
            if size[j][0]<size[i][0] and size[j][1]<size[i][1] and dp[j] > dp[i]:
                dp[i] = dp[j]
                dp_meta[i] = j
        dp[i] += 1
    max_dp = -1
    max_pos = 0
    for i in xrange(N):
        if dp[i] > max_dp:
            max_dp = dp[i]
            max_pos = i
    '''
    print size
    print dp
    print dp_meta
    print max_pos
    '''
    print max_dp
    path = [size[max_pos][-1]]
    while dp_meta[max_pos] != max_pos:
        max_pos = dp_meta[max_pos]
        path.append(size[max_pos][-1])
    print " ".join([str(x) for x in path[::-1]])
else:
    print 0


[N, w, h] = [int(x) for x in raw_input().strip().split(" ")]
size = []
for i in xrange(N):
    size.append([int(x) for x in raw_input().strip().split(" ")])
    size[-1].append(i+1)
size = [x for x in size if x[0]>w and x[1]>h]
size.sort()
N = len(size)
dp = [0]*N
dp[0] = 1
dp_meta = range(N)
for i in xrange(1,N):
    dp[i] = 0
    for j in xrange(i-1, -1, -1):
        if size[j][0]<size[i][0] and size[j][1]<size[i][1] and dp[j] > dp[i]:
            dp[i] = dp[j]
            dp_meta[i] = j
    dp[i] += 1
max_dp = -1
max_pos = 0
for i in xrange(N):
    if dp[i] > max_dp:
        max_dp = dp[i]
        max_pos = i
'''
print size
print dp
print dp_meta
print max_pos
'''
print max_dp
path = [size[max_pos][-1]]
while dp_meta[max_pos] != max_pos:
    max_pos = dp_meta[max_pos]
    path.append(size[max_pos][-1])
print " ".join([str(x) for x in path[::-1]])


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string s;

ll ss(int i,int j,char a){
	if(i==j){
		if(s[i]==a)return 0;
		else return 1;
	}
	ll c1=0,c2=0;
	for(int k=i;k<=(i+j)/2;k++){
		if(s[k]!=a)c1++;
	}
	for(int k=(i+j)/2+1;k<=j;k++){
		if(s[k]!=a)c2++;
	}

	return min(ss(i,(j+i)/2,a+1)+c2,c1+ss((j+i)/2+1,j,a+1));

}
int main() {
    ll t;
    cin>>t;
    while(t--){
    	ll n;
    	cin>>n;

    	cin>>s;

    	cout<<ss(0,n-1,'a')<<endl;

    }
	// your code goes here
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define en "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(auto s,char c,ll start,ll end ){
    if(start==end-1){
        return s[start]!=c;
    }
    ll cnt1=0;
    ll cnt2=0;

    ll len=(end-start+1);
    for(ll i=start;i<start+len/2;i++){
        if(s[i]!=c)cnt1++;
    }
    cnt1+=ff(s,(char)(c+1),start+len/2,end);

    for(ll i=start+len/2;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,(char)(c+1),start,start+len/2);

    return MIN(cnt1,cnt2);

}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=ff(s,'a',0,n);
    cout<<ans<<en;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define en "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string s,char c,ll start,ll end ){
    if(start==end-1){
        return s[start]!=c;
    }
    ll cnt1=0;
    ll cnt2=0;

    ll len=(end-start+1);
    for(ll i=start;i<start+len/2;i++){
        if(s[i]!=c)cnt1++;
    }
    cnt1+=ff(s,(char)(c+1),start+len/2,end);

    for(ll i=start+len/2;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,(char)(c+1),start,start+len/2);

    return MIN(cnt1,cnt2);

}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=ff(s,'a',0,n);
    cout<<ans<<en;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string &s,char c,ll start,ll end ){
if(start==end-1){
    return s[start]!=c;
}
ll cnt1=0;
ll cnt2=0;

ll mid=(start+end)/2;
for(ll i=start;i<mid;i++){
    if(s[i]!=c)cnt1++;
}
cnt1+=ff(s,c+1,mid,end);

    for(ll i=mid;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,c+1,start,mid);

    return MIN(cnt1,cnt2);

}

void solve(){
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll ans=ff(s,'a',0,n);
   cout<<ans<<endl;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string s,char c,ll start,ll end ){
    if(start==end-1){
        return s[start]!=c;
    }
    ll cnt1=0;
    ll cnt2=0;

    ll mid=(start+end)/2;
    for(ll i=start;i<mid;i++){
        if(s[i]!=c)cnt1++;
    }
    cnt1+=ff(s,(char)(c+1),mid,end);

    for(ll i=mid;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,(char)(c+1),start,mid);

    return MIN(cnt1,cnt2);

}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=ff(s,'a',0,n);
    cout<<ans<<endl;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string s,char c,ll start,ll end ){
    if(start==end-1){
        return s[start]!=c;
    }
    ll cnt1=0;
    ll cnt2=0;

  ll len=(end-start+1);
    for(ll i=start;i<start+len/2;i++){
        if(s[i]!=c)cnt1++;
    }
    cnt1+=ff(s,(char)(c+1),start+len/2,end);

    for(ll i=start+len/2;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,(char)(c+1),start,start+len/2);

    return MIN(cnt1,cnt2);

}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=ff(s,'a',0,n);
    cout<<ans<<endl;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string s,char c,ll start,ll end ){
if(start==end-1){
    return s[start]!=c;
}
ll cnt1=0;
ll cnt2=0;

ll mid=(start+end)/2;
for(ll i=start;i<mid;i++){
    if(s[i]!=c)cnt1++;
}
cnt1+=ff(s,c+1,mid,end);

    for(ll i=mid;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,c+1,start,mid);

    return MIN(cnt1,cnt2);

}

void solve(){
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll ans=ff(s,'a',0,n);
   cout<<ans<<endl;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define en "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

ll ff(string &s,char c,ll start,ll end ){
    if(start==end-1){
        return s[start]!=c;
    }
    ll cnt1=0;
    ll cnt2=0;

    ll len=(end-start+1);
    for(ll i=start;i<start+len/2;i++){
        if(s[i]!=c)cnt1++;
    }
    cnt1+=ff(s,(char)(c+1),start+len/2,end);

    for(ll i=start+len/2;i<end;i++){
        if(s[i]!=c)cnt2++;
    }
    cnt2+=ff(s,(char)(c+1),start,start+len/2);

    return MIN(cnt1,cnt2);

}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=ff(s,'a',0,n);
    cout<<ans<<en;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
    // t=1;
    cin>>t;
    // cin.ignore();
    while(t--){

        solve();
    }

    return 0;

}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int dfs(int l,int r,char c){
    if(l==r)
        return x[l]!=c;
    int num1=0,num2=0,mid=(l+r)>>1;
    for(int i=l;i<=mid;i++){
        if(x[i]!=c)
            num1++;
    }
    for(int i=mid+1;i<=r;i++){
        if(x[i]!=c)
            num2++;
    }
    num1+=dfs(mid+1,r,c+1);
    num2+=dfs(l,mid,c+1);
    return min(num1,num2);

}
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        ans=dfs(0,n-1,'a');
        printf("%lld\n",ans);
    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

            for(int i=s;i<s+n/2;i++){
                if(x[i]==now)
                    f++;
                else if(x[i]<=now+log(n)/log(2)-1&&x[i]>now)
                    f2++;
            }
            for(int i=s+n/2;i<=s+n-1;i++){
                if(x[i]==now)
                    e++;
                else if(x[i]<=now+log(n)/log(2)-1&&x[i]>now)
                    e2++;
            }
            if(f+e2>e+f2){
                ans+=n/2-f;
                s=s+n/2;
            }
            else
                ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

        for(int i=s;i<s+n/2;i++){
            if(x[i]==now)
                f++;
            else if(x[i]<=now+log(n)/log(2)&&x[i]>now)
                f2++;
        }
        for(int i=s+n/2;i<=s+n-1;i++){
            if(x[i]==now)
                e++;
            else if(x[i]<=now+log(n)/log(2)&&x[i]>now)
                e2++;
        }
        if(f+e2>e+f2){
            ans+=n/2-f;
            s=s+n/2;
        }
        else
            ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

            for(int i=s;i<s+n/2;i++){
                if(x[i]==now)
                    f++;
                else if(x[i]<=now+log(n)/log(2)-1+eps&&x[i]>now)
                    f2++;
            }
            for(int i=s+n/2;i<=s+n-1;i++){
                if(x[i]==now)
                    e++;
                else if(x[i]<=now+log(n)/log(2)-1+eps&&x[i]>now)
                    e2++;
            }
            if(f+e2>e+f2){
                ans+=n/2-f;
                s=s+n/2;
            }
            else
                ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

            for(int i=s;i<s+n/2;i++){
                if(x[i]==now)
                    f++;
                else if(x[i]<=now+log(n)/log(2)+eps&&x[i]>now)
                    f2++;
            }
            for(int i=s+n/2;i<=s+n-1;i++){
                if(x[i]==now)
                    e++;
                else if(x[i]<=now+log(n)/log(2)+eps&&x[i]>now)
                    e2++;
            }
            if(f+e2>e+f2){
                ans+=n/2-f;
                s=s+n/2;
            }
            else
                ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

        for(int i=s;i<s+n/2;i++){
            if(x[i]==now)
                f++;
            else if(x[i]<=now+log(n)/log(2)+0.5&&x[i]>now)
                f2++;
        }
        for(int i=s+n/2;i<=s+n-1;i++){
            if(x[i]==now)
                e++;
            else if(x[i]<=now+log(n)/log(2)+0.5&&x[i]>now)
                e2++;
        }
        if(f+e2>e+f2){
            ans+=n/2-f;
            s=s+n/2;
        }
        else
            ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,s,f,e,f2,e2,f3,e3;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }

        for(int i=s;i<s+n/2;i++){
            if(x[i]==now)
                f++;
            else if(x[i]<=now+log(n)/log(2)+0.1&&x[i]>now)
                f2++;
        }
        for(int i=s+n/2;i<=s+n-1;i++){
            if(x[i]==now)
                e++;
            else if(x[i]<=now+log(n)/log(2)+0.1&&x[i]>now)
                e2++;
        }
        if(f+e2>e+f2){
            ans+=n/2-f;
            s=s+n/2;
        }
        else
            ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,s+n/2,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
int t,n,k,dig[300005],no,num1,num2,f,e,s,f2,e2;
char x[131078],now;
long long ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        scanf("%s",&x);
        now='a';
        ans=0;
        s=0;
        while(n){
            f=0;
            e=0;
            f2=0;
            e2=0;
            if(n==1){
                if(x[s]!=now)
                    ans++;
                break;
            }
        for(int i=s;i<s+n/2;i++){
            if(x[i]==now)
                f++;
            if(x[i]==now+1)
                f2++;
        }
        for(int i=s+n/2;i<=s+n-1;i++){
            if(x[i]==now)
                e++;
            else if(x[i]==now+1)
                e2++;
        }
        if(f>e||(f==e&&f2<e2)){
            ans+=n/2-f;
            s=s+n/2;
        }
        else
            ans+=n/2-e;
            //printf("s=%d n=%d ans=%lld\n",s,n,ans);
            n/=2;
            now++;
        }
        printf("%lld\n",ans);

    }
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    ll repfirst=0,repsecond=0;
    for(ll i=0;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;
      //  cout<<c<<" "<<repfirst<<" :"<<repsecond<<endl;
    if(repfirst<repsecond)
        return repfirst+dc(s,mid,n,c+1);
    else if(repfirst>repsecond)
        return repsecond+dc(s,l,mid-1,c+1);
    return repfirst+min(dc(s,mid,n,c+1),dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    //cout<<c<<"::"<<l<<"-"<<mid<<"-"<<n<<endl;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;

    if(repfirst==0)
            return repfirst+dc(s,mid,n,c+1);
    else if(repsecond==0)
            return repsecond+dc(s,l,mid-1,c+1);
    return min(repfirst+dc(s,mid,n,c+1),repsecond+dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

string s;

ll   dc(int l,int n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    int mid=(n+l)>>1;
    int repfirst=0,repsecond=0;
    for(int i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    ll p=repfirst+dc(mid,n,c+1);
    for(int i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    return min(p,repsecond+dc(l,mid,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        cin>>s;
        cout<<dc(0,n,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l)>>1;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    ll p=repfirst+dc(s,mid,n,c+1);
    return min(p,repsecond+dc(s,l,mid,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    //cout<<c<<"::"<<l<<"-"<<mid<<"-"<<n<<endl;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;

    return min(repfirst+dc(s,mid,n,c+1),repsecond+dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    //cout<<c<<"::"<<l<<"-"<<mid<<"-"<<n<<endl;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;

    if(repfirst< repsecond && repfirst>mid/2)
            return repsecond+dc(s,l,mid-1,c+1);
    else if(repsecond<repfirst && repsecond>mid/2)
            return repfirst+dc(s,mid,n,c+1);
    return min(repfirst+dc(s,mid,n,c+1),repsecond+dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void checkmin(ll & a, ll b) {
        if (a > b)
            a = b;
}
ll   dc(string s,ll l,ll n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l)>>1;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    ll p=repfirst+dc(s,mid,n,c+1);
     checkmin(p,repsecond+dc(s,l,mid,c+1));
     return p;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
string s;

ll   dc(ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    //cout<<c<<"::"<<l<<"-"<<mid<<"-"<<n<<endl;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;

    return min(repfirst+dc(mid,n,c+1),repsecond+dc(l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    ll repfirst=0,repsecond=0;
    for(ll i=0;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;
      //  cout<<c<<" "<<repfirst<<" :"<<repsecond<<endl;
//    if(repfirst<repsecond)
//        return repfirst+dc(s,mid,n,c+1);
//    else if(repfirst>repsecond)
//        return repsecond+dc(s,l,mid-1,c+1);
    return min(repfirst+dc(s,mid,n,c+1),repsecond+dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,int l,int n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    int mid=(n+l)>>1;
    int repfirst=0,repsecond=0;
    for(int i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    ll p=repfirst+dc(s,mid,n,c+1);
    for(int i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    return min(p,repsecond+dc(s,l,mid,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,ll l,ll n,char c)
{
    if((n-l+1)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    ll mid=(n+l+1)/2;
    ll repfirst=0,repsecond=0;
    for(ll i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(ll i=mid;i<=n;i++)
        if(s[i]!=c)repsecond++;
    ll p=repfirst+dc(s,mid,n,c+1);
    return min(p,repsecond+dc(s,l,mid-1,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n-1,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

 void checkMin(ll & a, ll b) {
        if (a > b)
            a = b;
    }
ll   dc(string s,int l,int n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    int mid=(n+l)>>1;
    int repfirst=0,repsecond=0;
    for(int i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    ll p=repfirst+dc(s,mid,n,c+1);
    for(int i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    checkMin(p,repsecond+dc(s,l,mid,c+1));
return p;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n,'a')<<endl;

    }
return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll   dc(string s,int l,int n,char c)
{
    if((n-l)==1 )
       {if( s[l]==c )return 0;
       else return 1;}

    int mid=(n+l)>>1;
    int repfirst=0,repsecond=0;
    for(int i=l;i<mid;i++)
        if(s[i]!=c)repfirst++;
    for(int i=mid;i<n;i++)
        if(s[i]!=c)repsecond++;
    ll p=repfirst+dc(s,mid,n,c+1);
    return min(p,repsecond+dc(s,l,mid,c+1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    ll temp=0;
    ll a=0,b=0,c=0,d=0,p=0,q=0,x=0,y=0,z=0,n=0,m=0,sum=0,res=0,psum=0,mid=0,l=0,r=0;
    ll maxi=LONG_LONG_MIN,maxelement=0,mini=LONG_LONG_MAX;
    ll count=0,cnt=0,k=0;
    int flag=0;
    string s,str,ans;
    vector<ll >::iterator itr;
    vector<ll > vec2;
   // vector<ll> vec;
    unordered_map<ll,ll> mp;
    vector<string > vecs;
    typedef pair<ll,ll> pairs;
    set<ll> st;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        cin>>s;
        cout<<dc(s,0,n,'a')<<endl;

    }
return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        score += (26 - abs(a - k[i]));
    }
    return score;
}

int dp [20][131075];

int help (int left, int right, string k, int cnt[][26], int depth) {

    int a = 'a' + depth;
    if (a > 'z' || depth > 18 || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }

    if (dp[depth][left] != -1)
        return dp[depth][left];

    int len = (int)k.size() /  (1 << (depth + 1));
    int mid = left + len - 1;
    int leftCost = mid - left + 1 - (cnt[mid + 1][a - 'a'] - cnt[left][a - 'a']);
    int rightCost = right - mid - (cnt[right + 1][a - 'a'] - cnt[mid + 1][a - 'a']);

    return dp[depth][left] = min(leftCost + help(mid + 1, right, k, cnt, depth + 1), rightCost + help(left, mid, k, cnt, depth + 1));
}
int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int cnt[n + 1][26];
        for (auto & i : dp) for (int j = 0; j <= n; j++) i[j] = -1;
        for (int i = 0; i < 26; i++) cnt[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
            cnt[i][s[i - 1] - 'a']++;
        }
        cout << help(0, n - 1,  s, cnt, 0) << '\n';
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        if (k[i] != a)
            score++;
    }
    return score;
}

long help (long left, long right, string k, char a) {

    if (a > 'z' || a < 'a' || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }
    long mid = (left + right) / 2;
    long leftCost = dominantA(k, a, left, mid);
    long rightCost = dominantA(k, a, mid + 1, right);

    return min(leftCost + help(mid + 1, right, k, (char)(a + 1)), rightCost + help(left, mid, k, (char)(a + 1)));
}
int main() {
    //std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        cout << help(0, n - 1,  s,  'a') << '\n';
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        score += (26 - abs(a - k[i]));
    }
    return score;
}

long dp [20][131075];

long help (long left, long right, string k, long cnt[][26], long depth) {

    int a = 'a' + depth;
    if (a > 'z' || depth > 18 || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }
    if (dp[depth][left] != -1)
        return dp[depth][left];

    long mid = ((long)left + right + 1) / 2;
    mid--;
    long leftCost = mid - left + 1 - (cnt[mid + 1][a - 'a'] - cnt[left][a - 'a']);
    long rightCost = right - mid - (cnt[right + 1][a - 'a'] - cnt[mid + 1][a - 'a']);
    //if (k.size() == 131072 && right - left <= 1)
      //  cout << "left : " << left << " Right : " << right << " mid : " << mid << '\n';

    return dp[depth][left] = min(leftCost + help(mid + 1, right, k, cnt, depth + 1), rightCost + help(left, mid, k, cnt, depth + 1));
}
int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;

        long cnt[n + 1][26];
        for (auto & i : dp) for (int j = 0; j <= n; j++) i[j] = -1;
        for (int i = 0; i < 26; i++) cnt[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
            cnt[i][s[i - 1] - 'a']++;
        }
        cout << help(0, n - 1,  s, cnt, 0) << '\n';
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        score += (26 - abs(a - k[i]));
    }
    return score;
}

int dp [20][131075];

int help (int left, int right, string k, int cnt[][26], int depth) {

    int a = 'a' + depth;
    if (a > 'z' || depth > 18 || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }
    if (right < left)
        return (int)10e8;

    if (dp[depth][left] != -1)
        return dp[depth][left];

    int mid = ((long)left + right + 1) / 2;
    mid--;
    int leftCost = mid - left + 1 - (cnt[mid + 1][a - 'a'] - cnt[left][a - 'a']);
    int rightCost = right - mid - (cnt[right + 1][a - 'a'] - cnt[mid + 1][a - 'a']);
    if (k.size() == 131072 && right - left <= 10)
        cout << "left : " << left << " Right : " << right << " mid : " << mid << '\n';

    return dp[depth][left] = min(leftCost + help(mid + 1, right, k, cnt, depth + 1), rightCost + help(left, mid, k, cnt, depth + 1));
}
int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int cnt[n + 1][26];
        for (auto & i : dp) for (int j = 0; j <= n; j++) i[j] = -1;
        for (int i = 0; i < 26; i++) cnt[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
            cnt[i][s[i - 1] - 'a']++;
        }
        cout << help(0, n - 1,  s, cnt, 0) << '\n';
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        score += (26 - abs(a - k[i]));
    }
    return score;
}

int dp [20][131075];

int help (int left, int right, string k, int cnt[][26], int depth) {

    int a = 'a' + depth;
    if (a > 'z' || depth > 17 || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }

    if (dp[depth][left] != -1)
        return dp[depth][left];

    int mid = ((right - left) / 2) + left;
    int leftCost = mid - left + 1 - (cnt[mid + 1][a - 'a'] - cnt[left][a - 'a']);
    int rightCost = right - mid - (cnt[right + 1][a - 'a'] - cnt[mid + 1][a - 'a']);

    return dp[depth][left] = min(leftCost + help(mid + 1, right, k, cnt, depth + 1), rightCost + help(left, mid, k, cnt, depth + 1));
}
int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int cnt[n + 1][26];
        for (int i = 0; i <= 20; i++) for (int j = 0; j <= n; j++) dp[i][j] = -1;
        for (int i = 0; i < 26; i++) cnt[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
            cnt[i][s[i - 1] - 'a']++;
        }
        cout << help(0, n - 1,  s, cnt, 0) << '\n';
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <queue>
#include <cmath>
using std::vector;
using std::cin;
using std::cout;

using namespace std;

int dominantA (string k, char a, int left, int right) {

    int score = 0;
    for (int i = left; i <= right; i++) {
        score += (26 - abs(a - k[i]));
    }
    return score;
}

int dp [20][131075];

int help (int left, int right, string k, int cnt[][26], int depth) {

    int a = 'a' + depth;
    if (a > 'z' || depth > 17 || left > right || left < 0 || right >= k.size())
        return (int)10e8;

    if (left == right) {
        if (k[left] == a)
            return 0;
        else
            return 1;
    }

    if (dp[depth][left] != -1)
        return dp[depth][left];

    int mid = ((right - left) / 2) + left;
    int leftCost = mid - left + 1 - (cnt[mid + 1][a - 'a'] - cnt[left][a - 'a']);
    int rightCost = right - mid - (cnt[right + 1][a - 'a'] - cnt[mid + 1][a - 'a']);

    return dp[depth][left] = min(leftCost + help(mid + 1, right, k, cnt, depth + 1), rightCost + help(left, mid, k, cnt, depth + 1));
}
int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int cnt[n + 1][26];
        for (auto & i : dp) for (int j = 0; j <= n; j++) i[j] = -1;
        for (int i = 0; i < 26; i++) cnt[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
            cnt[i][s[i - 1] - 'a']++;
        }
        cout << help(0, n - 1,  s, cnt, 0) << '\n';
    }
    return 0;
}