Go: package main

// packed from [splaytree.go main.rmq.go splaytree_debug.go] with goone.

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

type SplayTreeNode struct {
	parent, left, right *SplayTreeNode

	size    int
	value   int
	minimum int
}

func newSplayTreeNode(v int) *SplayTreeNode {
	return &SplayTreeNode{value: v}
}

func (node *SplayTreeNode) rotate() {
	var pp, p, c *SplayTreeNode
	p = node.parent
	pp = p.parent
	if pp != nil && pp.left == p {
		pp.left = node
	}
	if pp != nil && pp.right == p {
		pp.right = node
	}
	node.parent = pp
	if p.left == node {
		c = node.right
		node.right = p
		p.left = c
	} else {
		c = node.left
		node.left = p
		p.right = c
	}
	p.parent = node
	if c != nil {
		c.parent = p
	}
	p.update()
	node.update()
}

func (node *SplayTreeNode) state() int {
	if node.parent == nil {
		return 0
	}
	if node.parent.left == node {
		return -1
	} else if node.parent.right == node {
		return 1
	}
	return 0
}

func (node *SplayTreeNode) splay() {
	for node.state() != 0 {
		if node.parent.state() == 0 {
			node.rotate()
			return
		}
		if node.state() == node.parent.state() {
			node.parent.rotate()
			node.rotate()
		} else {
			node.rotate()
			node.rotate()
		}
	}
}

func (node *SplayTreeNode) update() {
	node.size = 1
	node.minimum = node.value
	if node.left != nil {
		node.size += node.left.size
		node.minimum = min(node.minimum, node.left.minimum)
	}
	if node.right != nil {
		node.size += node.right.size
		node.minimum = min(node.minimum, node.right.minimum)
	}
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (node *SplayTreeNode) Get(idx int) *SplayTreeNode {
	cur := node
	for true {
		lSize := 0
		if cur.left != nil {
			lSize = cur.left.size
		}
		if idx < lSize {
			cur = cur.left
		}
		if lSize == idx {
			cur.splay()
			return cur
		}
		if idx > lSize {
			cur = cur.right
			idx = idx - lSize - 1
		}
	}
	return nil
}

func mergeSplayNode(l, r *SplayTreeNode) (root *SplayTreeNode) {
	if l == nil {
		return r
	}
	if r == nil {
		return l
	}
	root = l.Get(l.size - 1)
	root.right = r
	r.parent = root
	root.update()
	return root
}

func (node *SplayTreeNode) Split(leftCount int) (left *SplayTreeNode, right *SplayTreeNode) {
	root := node.Get(leftCount)
	lRoot, rRoot := root.left, root

	rRoot.left = nil
	if lRoot != nil {
		lRoot.parent = nil
	}
	rRoot.update()
	return lRoot, rRoot
}

func splayTreeInsert(t *SplayTreeNode, idx int, node *SplayTreeNode) (root *SplayTreeNode) {
	l, r := t.Split(idx)
	return mergeSplayNode(
		mergeSplayNode(l, node),
		r,
	)
}

func removeSplayTree(t *SplayTreeNode, idx int) (root *SplayTreeNode, removed *SplayTreeNode) {
	target := t.Get(idx)
	l, r := target.left, target.right
	if l != nil {
		l.parent = nil
	}
	if r != nil {
		r.parent = nil
	}
	target.left = nil
	target.right = nil
	target.update()
	return mergeSplayNode(l, r), target
}

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	q := scanInt(sc)
	table := newDebugNodeSlice(200001)
	for i := 0; i < n; i++ {
		table.l[i].parent = &table.l[i+1]
		table.l[i+1].left = &table.l[i]
		table.l[i].update()
		table.l[i+1].update()
	}
	var root *SplayTreeNode = &table.l[n]
	for i := 0; i < n; i++ {
		table.l[i].value = scanInt(sc)
		table.l[i].update()
	}
	table.l[n].update()
	for i := 0; i < q; i++ {
		switch scanInt(sc) {
		case 0:
			root = shift(root, scanInt(sc), scanInt(sc))
		case 1:
			l := scanInt(sc)
			r := scanInt(sc)
			tmp, rRoot := root.Split(r + 1)
			lRoot, cRoot := tmp.Split(l)
			fmt.Println(cRoot.minimum)
			root = mergeSplayNode(mergeSplayNode(lRoot, cRoot), rRoot)
		case 2:
			root = root.Get(scanInt(sc))
			root.value = scanInt(sc)
			root.update()
		}
	}
}


C++: #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

template<typename T, typename F> struct Treap{

    int gen(){
        static int x = 123456789;
        static int y = 362436069;
        static int z = 521288629;
        static int w = 88675123;
        int t;

        t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }

    struct Node{
        Node *l_ptr, *r_ptr;
        int sz, pri;
        T val, sum;
        Node(): l_ptr(nullptr), r_ptr(nullptr), sz(1), pri(0), val(T{}), sum(T{}){}
    };

    int n;
    vector<Node> nodes;
    F f;

    Treap(int n, T et, F f): n(n), f(f){
        nodes.resize(n);
        rep(i, n){
            nodes[i].val = nodes[i].sum = et;
        }
    }

    int size(Node *node){
        return node ? node->sz : 0;
    }

    void pull(Node *node){
        node->sz = size(node->l_ptr) + 1 + size(node->r_ptr);
        node->sum = node->val;
        if(node->l_ptr){
            node->sum = f(node->l_ptr->sum, node->sum);
        }
        if(node->r_ptr){
            node->sum = f(node->sum, node->r_ptr->sum);
        }
    }

    Node *merge(Node *l_node, Node *r_node){
        if(!l_node || !r_node) return l_node ? l_node : r_node;
        if(l_node->pri > r_node->pri){
            r_node->l_ptr = merge(l_node->r_ptr, r_node->l_ptr);
            l_node->r_ptr = r_node;
            pull(r_node);
            pull(l_node);
            return l_node;
        }
        else{
            l_node->r_ptr = merge(l_node->r_ptr, r_node->l_ptr);
            r_node->l_ptr = l_node;
            pull(l_node);
            pull(r_node);
            return r_node;
        }
    }

    pair<Node *, Node *> split(Node * node, int K){
        if(!node) return {node, node};
        if(size(node->l_ptr) >= K){
            auto p = split(node->l_ptr, K);
            node->l_ptr = p.se;
            pull(node);
            return {p.fi, node};
        }
        else{
            auto p = split(node->r_ptr, K-size(node->l_ptr)-1);
            node->r_ptr = p.fi;
            pull(node);
            return {node, p.se};
        }
    }

    Node *build(vector<int> &a, int l=0, int r=-1){
        if(r < 0) r = n;
        if(r-l == 0) return nullptr;
        else if(r-l == 1){
            nodes[l].pri = gen();
            nodes[l].val = nodes[l].sum = a[l];
            return &nodes[l];
        }
        else{
            return merge(build(a, l, (l+r)/2), build(a, (l+r)/2, r));
        }
    }

    pair<Node *, T> get_sum(Node *root, int l, int r){
        Node *l_root, *r_root;
        tie(l_root, r_root) = split(root, r);
        tie(l_root, root) = split(l_root, l);
        T ret = root->sum;
        root = merge(merge(l_root, root), r_root);
        return {root, ret};
    }

    Node *set_val(Node *node, int K, T x){
        if(size(node->l_ptr) == K) node->val = x;
        else if(size(node->l_ptr) > K) set_val(node->l_ptr, K, x);
        else set_val(node->r_ptr, K-size(node->l_ptr)-1, x);
        pull(node);
        return node;
    }

    Node *shiftr(Node *root, int l, int r){
        auto t = split(root, r);
        Node *a, *b, *c, *d;
        tie(a, b) = split(t.fi, l);
        tie(c, d) = split(t.se, 1);
        return merge(merge(a, c), merge(b, d));
    }
};

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    auto f = [](int x, int y){return min(x, y);};
    Treap<int, decltype(f)> st(n, mod, f);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    auto root = st.build(a);

    rep(_, q){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        if(x == 0){
            root = st.shiftr(root, y, z);
        }
        else if(x == 1){
            int ans;
            tie(root, ans) = st.get_sum(root, y, z+1);
            printf("%d\n", ans);
        }
        else{
            root = st.set_val(root, y, z);
        }
    }
}