package main

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

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

// var list []int

const DEF_VAL = 1<<31 - 1

// func Init(l *[]int, n int) {
// 	list = make([]int, n)
// 	for i := range list {
// 		list[i] = DEF_VAL
// 	}
// }
// func Update(i int, v int) {
// 	list[i] = v
// }

// func Find(begin int, end int) int {
// 	min := DEF_VAL
// 	for i := begin; i <= end; i++ {
// 		if list[i] < min {
// 			min = list[i]
// 		}
// 	}
// 	return min
// }

func Max(lhs int, rhs int) int {
	if lhs < rhs {
		return rhs
	} else {
		return lhs
	}
}
func Min(lhs int, rhs int) int {
	if lhs < rhs {
		return lhs
	} else {
		return rhs
	}
}

type Memo struct {
	minList   []int
	valueList []int
	numValue  int
}

func NewMemo(n int) Memo {
	valueList := make([]int, n)
	minList := make([]int, int(math.Ceil(float64(n)/float64(math.Floor(math.Sqrt(float64(n)))))))
	for i := range valueList {
		valueList[i] = DEF_VAL
	}
	for i := range minList {
		minList[i] = DEF_VAL
	}
	m := Memo{minList, valueList, int(math.Floor(math.Sqrt(float64(n))))}
	return m
}

func (this *Memo) Update(index int, value int) {
	this.valueList[index] = value
	indexes := this.GetIndexes(index, index)
	period := this.GetPeriod(index)
	// fmt.Printf("list:%v\n", this.minList)
	// fmt.Printf("index: %v\n", indexes)
	// fmt.Printf("[%d] <- %d, %v\n", index, value, period)
	min := DEF_VAL
	for _, i := range period {
		if this.valueList[i] < min {
			min = this.valueList[i]
		}
	}
	this.minList[indexes[0]] = min
}

func (this *Memo) Find(begin int, end int) int {
	// begin - end のと index の境界は異なるので、最初と最後は走査しないと正しくない
	indexes := this.GetIndexes(begin, end)
	// fmt.Printf("indexes:%v\n", indexes)
	min := DEF_VAL
	for i := indexes[0] + 1; i < indexes[len(indexes)-1]; i++ {
		if this.minList[i] < min {
			min = this.minList[i]
		}
	}
	beginEnd := Min(end, indexes[0]*this.numValue+this.numValue-1) //begin/this.numValue + (this.numValue - 1)
	for i := begin; i <= beginEnd && i <= end; i++ {
		if this.valueList[i] < min {
			min = this.valueList[i]
		}
	}
	endBegin := Max(begin, indexes[len(indexes)-1]*this.numValue)
	for i := endBegin; i <= end; i++ {
		if this.valueList[i] < min {
			min = this.valueList[i]
		}
	}
	// fmt.Printf("Find(%d, %d)\n BeginEnd: %d\n EndBegin: %d\n min: %d\n", begin, end, beginEnd, endBegin, min)
	// fmt.Printf("    %v\n", this.valueList)
	// fmt.Printf("    %v\n", indexes)
	return min
}

func (this *Memo) GetIndexes(begin int, end int) []int {
	// 範囲をカバーする minListのインデックスを計算する
	result := make([]int, 0)
	for i := begin; i <= end; i += this.numValue {
		x := i / this.numValue
		result = append(result, x)
	}
	return result
}

func (this *Memo) GetPeriod(index int) []int {
	begin := index / this.numValue * this.numValue
	end := begin + this.numValue - 1
	result := make([]int, 0)
	for i := begin; i <= end && i < len(this.valueList); i++ {
		result = append(result, i)
	}
	return result
}

func main() {
	con := NewConsole()
	defer con.Close()

	var n, q int
	fmt.Scanf("%d %d", &n, &q)
	lines, _ := ReadLongLines(q)

	list := NewMemo(n)

	for i := 0; i < q; i++ {
		args := strings.Split(lines[i], " ")
		command := args[0]
		switch command {
		case "0":
			i, _ := strconv.Atoi(args[1])
			x, _ := strconv.Atoi(args[2])
			list.Update(i, x)
		case "1":
			s, _ := strconv.Atoi(args[1])
			t, _ := strconv.Atoi(args[2])
			x := list.Find(s, t)
			// con.Printf("Find(%d, %d) ", s, t)
			con.Printf("%d\n", x)
		}
	}
	// fmt.Println(list)
}



Measured memory_bytes: 13252