Polycarp found a rectangular table consisting of $$$n$$$ rows and $$$m$$$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns":   cells are numbered starting from one;  cells are numbered from left to right by columns, and inside each column from top to bottom;  number of each cell is an integer one greater than in the previous cell. For example, if $$$n = 3$$$ and $$$m = 5$$$, the table will be numbered as follows:$$$$$$ \begin{matrix} 1 & 4 & 7 & 10 & 13 \\ 2 & 5 & 8 & 11 & 14 \\ 3 & 6 & 9 & 12 & 15 \\ \end{matrix} $$$$$$However, Polycarp considers such numbering inconvenient. He likes the numbering "by rows":   cells are numbered starting from one;  cells are numbered from top to bottom by rows, and inside each row from left to right;  number of each cell is an integer one greater than the number of the previous cell. For example, if $$$n = 3$$$ and $$$m = 5$$$, then Polycarp likes the following table numbering: $$$$$$ \begin{matrix} 1 & 2 & 3 & 4 & 5 \\ 6 & 7 & 8 & 9 & 10 \\ 11 & 12 & 13 & 14 & 15 \\ \end{matrix} $$$$$$Polycarp doesn't have much time, so he asks you to find out what would be the cell number in the numbering "by rows", if in the numbering "by columns" the cell has the number $$$x$$$?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow. Each test case consists of a single line containing three integers $$$n$$$, $$$m$$$, $$$x$$$ ($$$1 \le n, m \le 10^6$$$, $$$1 \le x \le n \cdot m$$$), where $$$n$$$ and $$$m$$$ are the number of rows and columns in the table, and $$$x$$$ is the cell number. Note that the numbers in some test cases do not fit into the $$$32$$$-bit integer type, so you must use at least the $$$64$$$-bit integer type of your programming language.

For each test case, output the cell number in the numbering "by rows".

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	i := 0
	fmt.Fscanf(in, "%d\n", &t)
	for {
		i++
		if i > t {
			break
		}
		var n, m, x int64
		fmt.Fscanf(in, "%v%v%v\n", &n, &m, &x)
		hang := (x - 1) / n
		lie := x - hang*n
		hang++
		lie--
		fmt.Fprintf(out, "%v\n", lie*m+hang)
	}
	return
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    fmt.Fscan(rd, &q)
    for t := 0; t < q; t++ {
        var n, m, x int64
        fmt.Fscan(rd, &n, &m, &x)
        x--
        r, c := x % n, x / n
        fmt.Println(r * m + c + 1)
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)

	for test := parseInt(getString(reader)); test > 0; test-- {
		nmx := getIntln(reader)
		n, m, x := nmx[0], nmx[1], nmx[2]
		y := m*(x-1) - ((x-1)/n)*(m*n-1) + 1
		writer.WriteString(fmt.Sprintln(y))
	}
	writer.Flush()
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int64 {
	b := strings.Split(getString(in), " ")
	res := make([]int64, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

package main

import "fmt"

func main() {

    var t int
	fmt.Scanf("%d", &t)
	for t > 0 {
		t--
		var n, m, x int64
		var s string
		fmt.Scanf("%s", &s)
		//fmt.Println(s)
		fmt.Scanf("%d%d%d", &n, &m, &x)
		//fmt.Println(n, m, x)
		x--
		i, j := x % n, x / n
		result := i * m + j
		result++
		fmt.Println(result)
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n, m, x := getI(), getI(), getI()
	var row int64
	var col int64

	row = x % n
	col = ceil(x, n)

	if row == 0 {
		row = n
	}

	out(row*m - m + col)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- HELPERS -------!
func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	sort.SliceStable(data, func(i, j int) bool { return data[i] < data[j] })
	return data
}

func nsorti(data ...int64) []int64 {
	idxs := make([]int64, len(data))
	for i := 0; i < len(data); i++ {
		idxs[i] = int64(i)
	}

	sort.SliceStable(idxs, func(i, j int) bool { return data[idxs[i]] < data[idxs[j]] })
	return idxs
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x,y,z int
		fmt.Scan(&x,&y,&z)
		var a,b,c,d int
		a= x*y
		b= a-z
		c= b%x
		d= b/x
		fmt.Println(a - ((c*y)+(d*1)))
	}
}

package main

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

func main() {

	input := bufio.NewReader(os.Stdin)
	var testCases int
	fmt.Fscan(input, &testCases)

	for testCases > 0 {
		testCases--
		var n ,m, x int64
		fmt.Fscan(input, &n, &m, &x)
		x--
		rows := x % n
		cols := x / n
		fmt.Println(rows * m + 1 + cols)
	}

}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)

	for q := 0; q < t; q += 1 {
		var n, m, x int64
		fmt.Scan(&n, &m, &x)

		if x % n != 0 {
			fmt.Printf("%d\n", x / n + 1 + m * ((x % n) - 1))
		} else {
			fmt.Printf("%d\n", x / n + m * (n - 1))
		}
	}
}

// http://codeforces.com/problemset/problem/1506/A

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		var a, b, n, m, x int64
		scanf("%d %d %d\n", &n, &m, &x)

		if x % n == 0 {
			a = n
			b = x / n
		} else {
			a = x % n
			b = (x / n) + 1
		}

		printf("%d\n", 1 + (m*(a-1)) + b-1)
	}
}

package main

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

func main() {
	var t int
	var m, n, d int64
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &m, &n, &d)
		col := d/m + 1
		row := d % m
		if row == 0 {
			row = m
			col -= 1
		}
		ans := (row-1)*n + col
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const EnoughSize = 10000

var io *bufio.ReadWriter
var rq chan interface{}

func init() {
	io = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))
	rq = make(chan interface{}, EnoughSize)
}

func rl() string {
	s, _ := io.ReadString('\n')
	return strings.TrimRight(s, "\r\n")
}

func ri() int64 {
	s := rl()
	i, _ := strconv.ParseInt(s, 0, 64)
	return i
}

func ris() []int64 {
	s := rl()
	ns := make([]int64, 0)
	splits := strings.Split(s, " ")
	for _, seg := range splits {
		i, _ := strconv.ParseInt(seg, 0, 64)
		ns = append(ns, i)
	}
	return ns
}

func flush() {
	for {
		r, ok := <-rq
		if !ok {
			break
		}
		fmt.Println(r)
	}
}

func submit(r interface{}) {
	rq <- r
}

func divmod(n, d int64) (q, r int64) {
	q = n / d
	r = n % d
	return
}

func main() {
	T := int(ri())
	for t := 0; t < T; t++ {
		ns := ris()
		p, q, x := ns[0], ns[1], ns[2]
		submit(solve(p, q, x))
	}
	close(rq)
	defer flush()
}

func solve(n, m, x int64) int64 {
	q, r := divmod(x, n)
	var xx, yy int64
	if r == 0 {
		xx = q - 1
		yy = n - 1
	} else {
		xx = q
		yy = r - 1
	}
	return xx + m*yy + 1
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int) int {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for i := 0; i < t; i++ {

		var n, m, x int64

		fmt.Fscan(input, &n)
		fmt.Fscan(input, &m)
		fmt.Fscan(input, &x)

		var Row, COL int64
		q := x % n
		if q > 0 {
			Row = int64(q)
			COL = int64(x/n) + 1
		} else {
			Row = n
			COL = int64(x / n)
		}
		var ANSWER int64
		ANSWER = int64(Row-1)*m + COL
		fmt.Println(ANSWER)
		// fmt.Println(Row)
		// fmt.Println(COL)

	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func ICeil(x float64) int64 {
	return int64(math.Ceil(x))
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, m, x := 0, int64(0), int64(0), int64(0)
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n, &m, &x)
		r, c := x%n, ICeil(float64(x)/float64(n))
		if r == 0 {
			r = n
		}
		fmt.Fprintln(w, (r-1)*m+c)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t       int
	n, m, x int64
)

func solve(n, m, x int64) int64 {
	column := (x + n - 1) / n
	row := x - (column-1)*n
	return (row-1)*m + column
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &m, &x)
		fmt.Println(solve(n, m, x))
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	//"math"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, m, x int64
		Fscan(in, &n, &m, &x)

		row, col := (x-1) % n + 1, x / n
		if x % n != 0 {
			col++
		}
		Fprintln(out, (row - 1) * m + col)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func decomposition(n int) []int {
	var res []int
	for p := 2; n >= p * p;  {
		if n % p == 0 {
			res = append(res, p)
			n /= p
		} else {
			p++
		}
	}
	if n > 1 {
		res = append(res, n)
	}
	return res
}

package main

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

func solve(n int64, m int64, x int64) int64 {
	numOfCols := ((x - 1) / n)
	start := numOfCols + 1
	different := x - numOfCols*n - 1
	return start + m*different
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int64(0)
		m := int64(0)
		x := int64(0)
		fmt.Fscanf(in, "%d %d %d\n", &n, &m, &x)
		fmt.Fprintf(out, "%d\n", solve(n, m, x))
		tt--
	}
	out.Flush()
}

package main

import "fmt"

func main() {
	var t, x, y, z, q, a, b int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i++ {
		fmt.Scan(&x, &y, &z)
		q = (z % x)
		if q == 0 {
			q = x
		}
		a = (q - 1) * y
		b = (z - q) / x
		fmt.Println(a + b + 1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1506A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1506A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1506A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1506A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1506A) NextInt64() uint64 {
	in.load()
	val, _ := strconv.ParseUint(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1506A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
 Run solve the problem CF1506A
 Date: 16/05/21
 User: pepradere
 URL: https://codeforces.com/problemset/problem/1506/A
 Problem: CF1506A
**/
func (in *CF1506A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n, m, x := in.NextInt64(), in.NextInt64(), in.NextInt64()
		x--
		a := x / n
		b := x % n
		res := (b * m) + a
		fmt.Println(res+1)
	}
}

func NewCF1506A(r *bufio.Reader) *CF1506A {
	return &CF1506A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1506A(bufio.NewReader(os.Stdin)).Run()
}

// 从给定cell号算出行列坐标即可。

package main

import "fmt"

func main() {
	var t, n, m, x int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i++ {
		fmt.Scan(&n, &m, &x)
		r, c := (x-1)%n, (x-1)/n
		result := r*m + c + 1
		fmt.Println(result)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var R, C, x int64
		fmt.Fscan(in, &R, &C, &x)
		x--
		c := x/R
		r := x%R
		fmt.Println(r*C+c+1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}

func (s *Scanner) next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}

func (s *Scanner) nextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.nextInt64()
	}
	return res
}

func min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.nextInt()
	for tc := 0; tc < TC; tc++ {
		N := sc.nextInt64()
		M := sc.nextInt64()
		x := sc.nextInt64()

		row := (x - 1) % N
		col := (x - 1) / N
		ans := row*M + col + 1
		fmt.Fprintln(wr, ans)
	}

}

package main

import "fmt"
import "math"

func solve(n,m,x int64) int64 {
	var i,j int64
	i = x % n
	if (i == 0) {
		i = n
	}
	j = int64(math.Ceil(float64(x) / float64(n)))
	return (i - 1)*m + j
}

func main() {
	var t int
	var n,m,x int64
	fmt.Scan(&t)
	for i := 0; i < int(t); i++ {
		fmt.Scan(&n,&m,&x)
		fmt.Println(solve(n,m,x))
	}
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		n, m, x := scanInt64(), scanInt64(), scanInt64()
		r, c := (x-1)%n, (x-1)/n
		fmt.Println(r*m + c + 1)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscanf(in, "%d\n", &T)
	for t := 0; t < T; t++ {
		var n int64
		var m int64
		var x int64

		fmt.Fscanf(in, "%d %d %d\n", &n, &m, &x)

		x--
		c := x / n

		r := x - c*n

		// fmt.Fprintf(out, "%d %d \n", c, r)
		ans := r*m + c
		fmt.Fprintf(out, "%v\n", ans+1)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n, m, x int64
		Fscan(in, &n, &m, &x)
		x--
		c, r := x/n, x%n
		Fprintln(out, r*m+c+1)
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	i := 0
	fmt.Fscanf(in, "%d\n", &t)
	for {
		i++
		if i > t {
			break
		}
		var n, m, x int
		fmt.Fscanf(in, "%d %d %d\n", &n, &m, &x)
		hang := (x - 1) / n
		lie := x - hang*n
		hang++
		lie--
		fmt.Fprintf(out, "%v\n", lie*m+hang)
	}
	return
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    for t := 0; t < q; t++ {
        var n, m, x int64
        fmt.Fscan(rd, &n, &m, &x)
        x--
        r, c := x % n, x / n
        fmt.Println(r * m + c + 1)
    }
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    for t := 0; t < q; t++ {
        var n, m, x int
        fmt.Fscan(rd, &n, &m, &x)
        x--
        r, c := x % n, x / n
        fmt.Println(r * m + c + 1)
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)

	for test := parseInt(getString(reader)); test > 0; test-- {
		nmx := getIntln(reader)
		n, m, x := nmx[0], nmx[1], nmx[2]
		var i int
		for i = 0; i < n; i++ {
			if (x-1-i)%n == 0 {
				break
			}
		}
		y := (x + n + (n*m-1)*i - 1) / n
		writer.WriteString(fmt.Sprintln(y))
	}
	writer.Flush()
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int {
	b := strings.Split(getString(in), " ")
	res := make([]int, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x,y,z int
		fmt.Scan(&x,&y,&z)
		if x*y == z {
			fmt.Println(z)
		} else if z%x >=1 {
			fmt.Println((z/x)+1+(y*((z%x)-1)))
		} else {
			fmt.Println((z/x)+(y*(z/x)))
		}
	}
}

package main

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

func main() {

	input := bufio.NewReader(os.Stdin)
	var testCases int
	fmt.Fscan(input, &testCases)

	for testCases > 0 {
		testCases--
		var n ,m, x int
		fmt.Fscan(input, &n, &m, &x)
		x--
		rows := x % n
		cols := x / n
		fmt.Println(rows * m + 1 + cols)
	}

}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)

	for q := 0; q < t; q += 1 {
		var n, m, x int
		fmt.Scan(&n, &m, &x)

		if x % n != 0 {
			fmt.Printf("%d\n", x / n + 1 + m * ((x % n) - 1))
		} else {
			fmt.Printf("%d\n", x / n + m * (n - 1))
		}
	}
}

// http://codeforces.com/problemset/problem/1506/A

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		var a, b, n, m, x int
		scanf("%d %d %d\n", &n, &m, &x)

		if x % n == 0 {
			a = n
			b = x / n
		} else {
			a = x % n
			b = (x / n) + 1
		}

		printf("%d\n", 1 + (m*(a-1)) + b-1)
	}
}

package main

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

func main() {
	var t, m, n, d int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &m, &n, &d)
		col := d/m + 1
		row := d % m
		if row == 0 {
			row = m
			col -= 1
		}
		ans := (row-1)*n + col
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int) int {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for i := 0; i < t; i++ {

		var n, m, x int

		fmt.Fscan(input, &n)
		fmt.Fscan(input, &m)
		fmt.Fscan(input, &x)

		Row := 0
		COL := 0
		q := x % n
		if q > 0 {
			Row = q
			COL = int(x/n) + 1
		} else {
			Row = n
			COL = int(x / n)
		}

		ANSWER := (Row-1)*m + COL
		fmt.Println(ANSWER)
		// fmt.Println(Row)
		// fmt.Println(COL)

	}

}


You are given a string $$$s$$$ consisting of lowercase Latin letters and $$$q$$$ queries for this string.Recall that the substring $$$s[l; r]$$$ of the string $$$s$$$ is the string $$$s_l s_{l + 1} \dots s_r$$$. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".There are two types of queries:   $$$1~ pos~ c$$$ ($$$1 \le pos \le |s|$$$, $$$c$$$ is lowercase Latin letter): replace $$$s_{pos}$$$ with $$$c$$$ (set $$$s_{pos} := c$$$);  $$$2~ l~ r$$$ ($$$1 \le l \le r \le |s|$$$): calculate the number of distinct characters in the substring $$$s[l; r]$$$.

The first line of the input contains one string $$$s$$$ consisting of no more than $$$10^5$$$ lowercase Latin letters. The second line of the input contains one integer $$$q$$$ ($$$1 \le q \le 10^5$$$) — the number of queries. The next $$$q$$$ lines contain queries, one per line. Each query is given in the format described in the problem statement. It is guaranteed that there is at least one query of the second type.

For each query of the second type print the answer for it — the number of distinct characters in the required substring in this query.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"math/rand"
	"time"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

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

type vector_i []int
func (v *vector_i) pb(x int) {
	*v=append(*v,x)
}
func (v *vector_i) size() int {
	return len(*v)
}
func (v *vector_i) pop() {
	if !(*v).empty() {
		*v=(*v)[:len(*v)-1]
	}
}
func (v *vector_i) reverse() {
	n:=(*v).size()
	for i:=0;i*2<n;i++ {
		(*v)[i],(*v)[n-i-1]=(*v)[n-i-1],(*v)[i]
	}
}
func (v *vector_i) clear() {
	*v=(*v)[:0]
}
func (v *vector_i) empty() bool {
	return (*v).size()==0
}
func (v *vector_i) sort() {
	sort.Slice(*v, func (i, j int) bool {
		return (*v)[i]<(*v)[j]
	})
}
type fun_ii_b func (i, j int) bool
func (v *vector_i) sort_fun(f fun_ii_b) {
	sort.Slice(*v,f)
}
func (v *vector_i) lb(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) ub(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<=x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) del(pos int) {
	if pos>=0 && pos<len(*v) {
		for i:=pos;i<len(*v)-1;i++ {
			(*v)[i]=(*v)[i+1]
		}
		(*v).pop()
	}
}
func (v *vector_i) ins(pos, val int) {
	(*v).pb(0)
	for i:=len(*v)-1;i>pos;i-- {
		(*v)[i]=(*v)[i-1]
	}
	(*v)[pos]=val
}
func (v *vector_i) substr(l, r int) vector_i {
	var ans vector_i=make(vector_i,r-l+1)
	for i:=l;i<=r;i++ {
		ans.pb((*v)[i])
	}
	return ans
}
func (v *vector_i) resize(n int) {
	for len(*v)>n {
		(*v).pop()
	}
	for len(*v)<n {
		(*v).pb(0)
	}
}

type Treap struct {
	ls,rs,sz,x,y vector_i
	root int
	multi bool
}
func (t *Treap) init(multi bool) {
	t.ls.resize(1)
	t.rs.resize(1)
	t.sz.resize(1)
	t.x.resize(1)
	t.y.resize(1)
	t.root=0
	t.multi=multi
	rand.Seed(time.Now().UnixNano())
}
const lim_rand int=2000000000
func (t *Treap) MakeNode(x int) int {
	t.ls.pb(0)
	t.rs.pb(0)
	t.sz.pb(1)
	t.x.pb(x)
	t.y.pb(rand.Intn(lim_rand))
	return t.x.size()-1;
}
func (t *Treap) val(c int) int {
	return t.x[c]
}
func (t *Treap) pull(c int) {
	t.sz[c]=t.sz[t.ls[c]]+1+t.sz[t.rs[c]]
}
func (t *Treap) upd(c int) {

}
func (t *Treap) push(c int) {

}
func (t *Treap) Split_val(c int, l,r *int, x int) {
	if c==0 {
		*l=0
		*r=0
	} else {
		(*t).push(c)
		if t.x[c]<=x {
			*l=c
			(*t).Split_val(t.rs[c],&t.rs[*l],r,x)
		} else {
			*r=c
			(*t).Split_val(t.ls[c],l,&t.ls[*r],x)
		}
		(*t).pull(c)
	}
}
func (t *Treap) Split_sz(c int, l,r *int, k int) {
	if c==0 {
		*l=0
		*r=0
	} else {
		(*t).push(c)
		if t.sz[t.ls[c]]+1<=k {
			*l=c
			(*t).Split_sz(t.rs[c],&t.rs[*l],r,k-t.sz[t.ls[c]]-1)
		} else {
			*r=c
			(*t).Split_sz(t.ls[c],l,&t.ls[*r],k)
		}
		(*t).pull(c)
	}
}
func (t *Treap) Merge(c *int, l,r int) {
	if l==0 || r==0 {
		*c=l^r;
	} else {
		if t.y[l]>t.y[r] {
			(*t).push(l)
			*c=l
			(*t).Merge(&t.rs[*c],t.rs[l],r)
		} else {
			(*t).push(r)
			*c=r
			(*t).Merge(&t.ls[*c],l,t.ls[r])
		}
		(*t).pull(*c)
	}
}
func (t *Treap) Search_pos(c,k int) int {
	if c==0 {
		return 0
	} else {
		(*t).push(c)
		if t.sz[t.ls[c]]+1==k {
			return c
		} else if t.sz[t.ls[c]]+1<k {
			return (*t).Search_pos(t.rs[c],k-t.sz[t.ls[c]]-1)
		} else {
			return (*t).Search_pos(t.ls[c],k)
		}
	}
}
func (t *Treap) has(c,x int) bool {
	if c==0 {
		return false
	} else {
		(*t).push(c)
		if t.x[c]==x {
			return true
		} else if t.x[c]<x {
			return (*t).has(t.rs[c],x)
		} else {
			return (*t).has(t.ls[c],x)
		}
	}
}
func (t *Treap) ins(x int) {
	if t.multi || !(*t).has(t.root,x) {
		tmp:=(*t).MakeNode(x)
		var a,b int=0,0
		(*t).Split_val(t.root,&a,&b,x)
		(*t).Merge(&t.root,a,tmp)
		(*t).Merge(&t.root,t.root,b)
	}
}
func (t *Treap) del_val(x int) {
	var a,b,c int=0,0,0
	(*t).Split_val(t.root,&a,&b,x-1)
	(*t).Split_val(b,&b,&c,x)
	(*t).Merge(&t.root,a,c)
}
func (t *Treap) del_pos(k int) {
	var a,b,c int=0,0,0
	(*t).Split_sz(t.root,&a,&b,k-1)
	(*t).Split_sz(b,&b,&c,1)
	(*t).Merge(&t.root,a,c)
}
func (t *Treap) at(k int) int {
	return (*t).Search_pos(t.root,k)
}
func (t *Treap) val_at(k int) int {
	return t.x[(*t).at(k)]
}
func (t *Treap) Search_lb(c,x int) int {
	if c==0 {
		return 0
	} else {
		(*t).push(c)
		if t.x[c]==x {
			return c
		} else if t.x[c]<x {
			return (*t).Search_lb(t.rs[c],x)
		} else {
			ans:=(*t).Search_lb(t.ls[c],x)
			if ans==0 {
				ans=c
			}
			return ans
		}
	}
}
func (t *Treap) lb(x int) int {
	return (*t).Search_lb(t.root,x)
}
func (t *Treap) ub(x int) int {
	return (*t).Search_lb(t.root,x+1)
}
func (t *Treap) size() int {
	return t.sz[t.root]
}
func (t *Treap) print(c int) {
	if c!=0 {
		(*t).print(t.ls[c])
		printf("(%d %d) ",t.x[c],t.sz[c])
		(*t).print(t.rs[c])
	}
}

func main() {

	defer writer.Flush()

	var st [26]Treap
	for i:=0;i<26;i++ {
		st[i].init(false)
	}
	var str string
	var byt []byte
	byt=append(byt,0)
	scanf("%s\n",&str)
	for i:=1;i<=len(str);i++ {
		x:=int(str[i-1])-int('a')
		byt=append(byt,str[i-1])
		st[x].ins(i)
	}
	var q int
	scanf("%d\n",&q)
	for ;q>0;q-- {
		var t int
		scanf("%d ",&t)
		if t==1 {
			var p int
			var c byte
			scanf("%d %c\n",&p,&c)
			x:=int(byt[p])-int('a')
			y:=int(c)-int('a')
			byt[p]=c
			st[x].del_val(p)
			st[y].ins(p)
		} else {
			var l,r int
			scanf("%d %d\n",&l,&r)
			ans:=0
			for i:=0;i<26;i++ {
				lb:=st[i].lb(l)
				if lb!=0 && st[i].val(lb)<=r {
					ans++
				}
			}
			printf("%d\n",ans)
		}
	}
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int
var bits [ALPHABET_NUM]*BinaryIndexedTree

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS := len(S)

	for i := 0; i < ALPHABET_NUM; i++ {
		bits[i] = NewBIT(lenS)
	}

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		bits[c].Add(i+1, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			bits[newcint].Add(idx, 1)
			bits[oldcint].Add(idx, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := bits[alpha].Sum(r) - bits[alpha].Sum(l-1)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// Public methods
// bit := NewBIT(200000 + 5)
// s := bit.Sum(i) 						// Sum of [1, i] (1-based)
// bit.Add(i, x) 							// Add x to i (1-based)
// idx := bit.LowerBound(w) 	// minimum idx such that bit.Sum(idx) >= w

type BinaryIndexedTree struct {
	bit     []int
	n       int
	minPow2 int
}

// n(>=1) is number of elements of original data
func NewBIT(n int) *BinaryIndexedTree {
	newBit := new(BinaryIndexedTree)

	newBit.bit = make([]int, n+1)
	newBit.n = n

	newBit.minPow2 = 1
	for {
		if (newBit.minPow2 << 1) > n {
			break
		}
		newBit.minPow2 <<= 1
	}

	return newBit
}

// Sum of [1, i](1-based)
func (b *BinaryIndexedTree) Sum(i int) int {
	s := 0

	for i > 0 {
		s += b.bit[i]
		i -= i & (-i)
	}

	return s
}

// Add x to i(1-based)
func (b *BinaryIndexedTree) Add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & (-i)
	}
}

// LowerBound returns minimum i such that bit.Sum(i) >= w.
func (b *BinaryIndexedTree) LowerBound(w int) int {
	if w <= 0 {
		return 0
	}

	x := 0
	for k := b.minPow2; k > 0; k /= 2 {
		if x+k <= b.n && b.bit[x+k] < w {
			w -= b.bit[x+k]
			x += k
		}
	}

	return x + 1
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var S []rune
var q int
var memo [26][100000 + 5]int

// [1, n]
var bit [26][100000 + 5]int
var lenS int

// var n int
// var A []int

func sum(i, alpha int) int {
	s := 0

	for i > 0 {
		s += bit[alpha][i]
		i -= i & (-i)
	}

	return s
}

func add(i, alpha, x int) {
	// for i <= n {
	for i <= lenS {
		bit[alpha][i] += x
		i += i & (-i)
	}
}

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS = len(S)

	for i := 0; i < len(S); i++ {
		r := S[i]
		n := int(r - 'a')
		// for j := 0; j < ALPHABET_NUM; j++ {
		// 	if n == j {
		// 		memo[j][i+1] = memo[j][i] + 1
		// 	} else {
		// 		memo[j][i+1] = memo[j][i]
		// 	}
		// }
		add(i+1, n, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			c := R[0]
			cAlpha := int(c - 'a')
			oldc := S[idx-1]
			oldcAlpha := int(oldc - 'a')

			add(idx, cAlpha, 1)
			add(idx, oldcAlpha, -1)
			S[idx-1] = c
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := sum(r, alpha) - sum(l-1, alpha)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// type BinaryIndexedTree struct {
// 	bit []int
// 	n   int
// }

// func NewBIT(n int) *BinaryIndexedTree {
// 	newBit := new(BinaryIndexedTree)

// 	newBit.bit = make([]int, n+1)
// 	newBit.n = n

// 	return newBit
// }

// func (b *BinaryIndexedTree) Sum(i int) int {
// 	s := 0

// 	for i > 0 {
// 		s += b.bit[i]
// 		i -= i & (-i)
// 	}

// 	return s
// }

// func (b *BinaryIndexedTree) Add(i, x int) {
// 	for i <= b.n {
// 		b.bit[i] += x
// 		i += i & (-i)
// 	}
// }

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int
var bits [ALPHABET_NUM]*BinaryIndexedTree

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS := len(S)

	for i := 0; i < ALPHABET_NUM; i++ {
		bits[i] = NewBIT(lenS)
	}

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		bits[c].Add(i+1, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			bits[newcint].Add(idx, 1)
			bits[oldcint].Add(idx, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := bits[alpha].Sum(r) - bits[alpha].Sum(l-1)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

type BinaryIndexedTree struct {
	bit []int
	n   int
}

func NewBIT(n int) *BinaryIndexedTree {
	newBit := new(BinaryIndexedTree)

	newBit.bit = make([]int, n+1)
	newBit.n = n

	return newBit
}

// Sum of [1, i]
func (b *BinaryIndexedTree) Sum(i int) int {
	s := 0

	for i > 0 {
		s += b.bit[i]
		i -= i & (-i)
	}

	return s
}

// Add x to i(1-based)
func (b *BinaryIndexedTree) Add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & (-i)
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int

// [1, n]
var bit [ALPHABET_NUM][100000 + 5]int
var lenS int

func sum(i, alpha int) int {
	s := 0

	for i > 0 {
		s += bit[alpha][i]
		i -= i & (-i)
	}

	return s
}

func add(i, alpha, x int) {
	for i <= lenS {
		bit[alpha][i] += x
		i += i & (-i)
	}
}

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS = len(S)

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		add(i+1, c, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			add(idx, newcint, 1)
			add(idx, oldcint, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := sum(r, alpha) - sum(l-1, alpha)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var pc [256]byte

func init() {
	for i := range pc {
		pc[i] = pc[i/2] + byte(i&1)
	}
}

func PopCount(x uint32) int {
	return int(pc[byte(x)] +
		pc[byte(x>>8)] +
		pc[byte(x>>16)] +
		pc[byte(x>>24)])
}

func main() {
	f(os.Stdin, os.Stdout)
}

type Block struct {
	Mask  uint32
	Items []uint32
}

func (b *Block) SetItem(pos int, item uint32) {
	b.Items[pos] = item
	b.Mask = 0
	for _, item := range b.Items {
		b.Mask |= item
	}
}

func (b *Block) GetMask(pos1, pos2 int) uint32 {
	mask := uint32(0)
	for i := pos1; i < pos2; i += 1 {
		mask |= b.Items[i]
	}

	return mask
}

func f(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	blockSize := 100
	blocks := make([]Block, 0)

	data := []byte(read(s))

	// Дополняем строку до длины блока
	sLen := len(data)
	z := 0
	if sLen < 8 {
		z = blockSize - sLen
	} else {
		z = blockSize - sLen%blockSize
	}
	data = append(data, make([]byte, z)...)

	// Разбиваем эл-ты на блоки
	for i := 0; i < len(data); i += blockSize {
		block := Block{
			Items: make([]uint32, blockSize),
		}
		for j := 0; j < blockSize; j += 1 {
			block.SetItem(j, 1<<(data[i+j]-'a'))
		}
		blocks = append(blocks, block)
	}

	q, _ := strconv.ParseUint(read(s), 10, 32)
	for i := 0; uint64(i) < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 64)
			n1 := (pos - 1) / uint64(blockSize)
			n2 := int(pos-1) % blockSize
			blocks[n1].SetItem(n2, 1<<(req[2][0]-'a'))
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 64)
			pos2, _ := strconv.ParseUint(req[2], 10, 64)

			n11 := (pos1 - 1) / uint64(blockSize)
			n12 := int(pos1-1) % blockSize
			n21 := (pos2) / uint64(blockSize)
			n22 := int(pos2) % blockSize

			counters := uint32(0)

			// Считаем биты крайних блоков
			if n11 == n21 {
				counters |= blocks[n11].GetMask(n12, n22)
			} else {
				counters |= blocks[n11].GetMask(n12, blockSize)
				counters |= blocks[n21].GetMask(0, n22)
				// считаем биты полных блоков
				for j := n11 + 1; j < n21; j++ {
					counters |= blocks[j].Mask
				}
			}

			_, _ = fmt.Fprintln(out, PopCount(counters))
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1234D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var s []byte
	Fscan(in, &s)
	for i := range s {
		s[i] -= 'a'
	}

	n := len(s)
	trees := make([][]int, 26)
	for i := range trees {
		trees[i] = make([]int, n+1)
	}
	add := func(tree []int, idx int, val int) {
		for ; idx <= n; idx += idx & -idx {
			tree[idx] += val
		}
	}
	sum := func(tree []int, idx int) (res int) {
		for ; idx > 0; idx &= idx - 1 {
			res += tree[idx]
		}
		return
	}
	query := func(tree []int, l, r int) int {
		return sum(tree, r) - sum(tree, l-1)
	}

	for i, c := range s {
		add(trees[c], i+1, 1)
	}
	var q, op int
	for Fscan(in, &q); q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var idx int
			var raw string
			Fscan(in, &idx, &raw)
			ch := raw[0] - 'a'
			add(trees[s[idx-1]], idx, -1)
			add(trees[ch], idx, 1)
			s[idx-1] = ch
		} else {
			var l, r int
			Fscan(in, &l, &r)
			res := 0
			for _, tree := range trees {
				if query(tree, l, r) > 0 {
					res++
				}
			}
			Fprintln(out, res)
		}
	}
}

func main() {
	Sol1234D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1234D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var s []byte
	Fscan(in, &s)
	for i := range s {
		s[i] -= 'a'
	}

	n := len(s)
	trees := make([][]int, 26)
	for i := range trees {
		trees[i] = make([]int, n+1)
	}
	add := func(tree []int, idx int, val int) {
		for ; idx <= n; idx += idx & -idx {
			tree[idx] += val
		}
	}
	sum := func(tree []int, idx int) (res int) {
		for ; idx > 0; idx &= idx - 1 {
			res += tree[idx]
		}
		return
	}
	query := func(tree []int, l, r int) int {
		return sum(tree, r) - sum(tree, l-1)
	}

	for i, c := range s {
		add(trees[c], i+1, 1)
	}
	var q, op int
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &op)
		if op == 1 {
			var idx int
			var raw string
			Fscan(in, &idx, &raw)
			ch := raw[0] - 'a'
			add(trees[s[idx-1]], idx, -1)
			add(trees[ch], idx, 1)
			s[idx-1] = ch
		} else {
			var l, r int
			Fscan(in, &l, &r)
			res := 0
			for i := range trees {
				if query(trees[i], l, r) > 0 {
					res++
				}
			}
			Fprintln(out, res)
		}
	}
}

func main() {
	Sol1234D(os.Stdin, os.Stdout)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	var ss string
	fmt.Fscanf(reader, "%s\n", &ss)

	s := []byte(ss)
	ll := len(ss)

	var data [101][26]int

	for i := 0; i*1000 < ll; i++ {

		for j := i * 1000; j < ll && j < (i+1)*1000; j++ {
			data[i][s[j]-'a']++
		}
	}

	var q int
	fmt.Fscanf(reader, "%d\n", &q)

	var t int
	var l, r int
	var c byte
	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d", &t)
		if t == 1 {
			fmt.Fscanf(reader, "%d %c\n", &l, &c)
			data[(l-1)/1000][s[l-1]-'a']--

			s[l-1] = c
			data[(l-1)/1000][s[l-1]-'a']++
		} else {
			fmt.Fscanf(reader, "%d %d\n", &l, &r)

			var ans [26]bool

			//[l-1, 1000x)
			for l = l - 1; l < r; l++ {
				if (l+1)%1000 == 0 {
					break
				}

				if !ans[s[l]-'a'] {
					ans[s[l]-'a'] = true
				}
			}

			//[1000x, 1000y)
			for ; (l+1)/1000 < r/1000; l += 1000 {
				k := (l + 1) / 1000
				for j := 0; j < 26; j++ {
					if !ans[j] && data[k][j] > 0 {
						ans[j] = true
					}
				}
			}

			//[1000y, r)
			for ; l < r; l++ {
				if !ans[s[l]-'a'] {
					ans[s[l]-'a'] = true
				}
			}

			//ans
			sum := 0
			for j := 0; j < 26; j++ {
				if ans[j] {
					sum++
				}
			}
			fmt.Printf("%d\n", sum)
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1234/D

package main

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

type ReplaceQuery struct {
	queryType int
	index     int
	char      string
}

type CalculateQuery struct {
	queryType int
	left      int
	right     int
}

func update(tree []int, index int, value int) {
	for index <= len(tree)-1 {
		tree[index] += value
		index += index & ^(index - 1)
	}
}

func sum(tree []int, index int) int {
	total := 0
	for index > 0 {
		total += tree[index]
		index -= index & ^(index - 1)
	}
	return total
}

func Solve(s string, n int, queries []interface{}) []int {
	trees := make([][]int, 26)
	for i := 0; i < 26; i++ {
		trees[i] = make([]int, len(s)+1)
	}
	for i := 1; i <= len(s); i++ {
		update(trees[s[i-1]-'a'], i, 1)
	}
	answers := []int{}
	b := []byte(s)
	for _, query := range queries {
		switch query.(type) {
		case ReplaceQuery:
			r := query.(ReplaceQuery)
			update(trees[b[r.index-1]-'a'], r.index, -1)
			b[r.index-1] = r.char[0]
			update(trees[b[r.index-1]-'a'], r.index, 1)
		case CalculateQuery:
			c := query.(CalculateQuery)
			distinct := 0
			for _, tree := range trees {
				if sum(tree, c.right)-sum(tree, c.left-1) > 0 {
					distinct += 1
				}
			}
			answers = append(answers, distinct)
		}
	}
	return answers
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var s string
	var n int
	fmt.Fscanf(reader, "%s\n%d\n", &s, &n)
	queries := make([]interface{}, n)
	for i := 0; i < n; i++ {
		var queryType int
		fmt.Fscanf(reader, "%d", &queryType)
		if queryType == 1 {
			r := ReplaceQuery{queryType, 0, ""}
			fmt.Fscanf(reader, "%d %s\n", &r.index, &r.char)
			queries[i] = r
		} else if queryType == 2 {
			c := CalculateQuery{queryType, 0, 0}
			fmt.Fscanf(reader, "%d %d\n", &c.left, &c.right)
			queries[i] = c
		}
	}

	answers := Solve(s, n, queries)
	for _, elem := range answers {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for j := range counters {
				counters[j] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var pc [256]byte

func init() {
	for i := range pc {
		pc[i] = pc[i/2] + byte(i&1)
	}
}

func PopCount(x uint32) int {
	return int(pc[byte(x)] +
		pc[byte(x>>8)] +
		pc[byte(x>>16)] +
		pc[byte(x>>24)])
}

func main() {
	f(os.Stdin, os.Stdout)
}

type Block struct {
	Mask  uint32
	Items []uint32
}

func (b *Block) SetItem(pos int, item uint32) {
	b.Items[pos] = item
	b.Mask = 0
	for _, item := range b.Items {
		b.Mask |= item
	}
}

func (b *Block) GetMask(pos1, pos2 int) uint32 {
	mask := uint32(0)
	for i := pos1; i < pos2; i += 1 {
		mask |= b.Items[i]
	}

	return mask
}

func f(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	blockSize := 10
	blocks := make([]Block, 0)

	data := []byte(read(s))

	// Дополняем строку до длины блока
	sLen := len(data)
	z := 0
	if sLen < 8 {
		z = blockSize - sLen
	} else {
		z = blockSize - sLen%blockSize
	}
	data = append(data, make([]byte, z)...)

	// Разбиваем эл-ты на блоки
	for i := 0; i < len(data); i += blockSize {
		block := Block{
			Items: make([]uint32, blockSize),
		}
		for j := 0; j < blockSize; j += 1 {
			block.SetItem(j, 1<<(data[i+j]-'a'))
		}
		blocks = append(blocks, block)
	}

	q, _ := strconv.ParseUint(read(s), 10, 32)
	for i := 0; uint64(i) < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 64)
			n1 := (pos - 1) / uint64(blockSize)
			n2 := int(pos-1) % blockSize
			blocks[n1].SetItem(n2, 1<<(req[2][0]-'a'))
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 64)
			pos2, _ := strconv.ParseUint(req[2], 10, 64)

			n11 := (pos1 - 1) / uint64(blockSize)
			n12 := int(pos1-1) % blockSize
			n21 := (pos2) / uint64(blockSize)
			n22 := int(pos2) % blockSize

			counters := uint32(0)

			// Считаем биты крайних блоков
			if n11 == n21 {
				counters |= blocks[n11].GetMask(n12, n22)
			} else {
				counters |= blocks[n11].GetMask(n12, blockSize)
				counters |= blocks[n21].GetMask(0, n22)
				// считаем биты полных блоков
				for j := n11 + 1; j < n21-1; j++ {
					counters |= blocks[j].Mask
				}
			}

			_, _ = fmt.Fprintln(out, PopCount(counters))
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100001), 100001)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем сколько различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 256)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 200*1024), 200*1024)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c] += 1
			}

			// Считаем сколько различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 1000002), 1000002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for j := range counters {
				counters[j] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}