#[allow(unused_imports)] use std::{*, io::*, cmp::*, char::*, collections::*, mem::* };
#[allow(unused)] macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
#[allow(unused)] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
#[allow(unused)] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1}; ($next:expr, [ $t:tt ]) => {{ let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}
#[allow(unused)] macro_rules! debug { ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap()); }
#[allow(unused)] macro_rules! debugln { ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap()); }

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    #[allow(unused)] macro_rules! puts { ($($format:tt)*) => (let _ = write!(out,$($format)*);); }

    let r = get();
    let c = get();
    let mut a = vec![vec!['c'; c]; r];
    // also input! is buggy. . .
    for i in 0..r {
        a[i] = get_word().chars().collect(); // that's uncool. . . keep forgetting how to do this with input!
    }

    let find = |x| {
        for i in 0..r {
            for j in 0..c {
                if x == a[i][j] {
                    return Some((i, j));
                }
            }
        }
        return None;
    };

    let exit = find('E').unwrap();
    let start = find('S').unwrap();

    let mut dist = vec![vec![-1; c]; r];

    (|s| { // bfs
        let mut q = VecDeque::<(usize, usize)>::new();
        q.push_back(s);
        dist[s.0][s.1] = 0;
        loop {
            if q.len() == 0 { break; }
            let v = q.pop_front().unwrap();
            let mut one = (1, 0);
            for _ in 0..4 {
                let w = (v.0 as i64 + one.0, v.1 as i64 + one.1);
                if 0 <= w.0 && w.0 < r as i64
                && 0 <= w.1 && w.1 < c as i64 {
                    let w = (w.0 as usize, w.1 as usize);
                    if a[w.0][w.1] != 'T' && dist[w.0][w.1] == -1 {
                        dist[w.0][w.1] = dist[v.0][v.1] + 1;
                        q.push_back((w.0, w.1));
                    }
                }
                one = (-one.1, one.0);
            }
        }
    })(exit);

    let mut cnt = 0;
    for i in 0..r {
        for j in 0..c {
            if (i, j) != start && (i, j) != exit && a[i][j] != 'T' && dist[i][j] <= dist[start.0][start.1] {
                cnt += a[i][j] as i64 - '0' as i64;
            }
        }
    }
    print!("{}", cnt);
}
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

#[allow(dead_code)]
fn get_word() -> String {
      let stdin = std::io::stdin();
      let mut stdin=stdin.lock();
      let mut u8b: [u8; 1] = [0];
      loop {
          let mut buf: Vec<u8> = Vec::with_capacity(16);
          loop {
              let res = stdin.read(&mut u8b);
              if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                  break;
              } else {
                  buf.push(u8b[0]);
              }
          }
          if buf.len() >= 1 {
              let ret = String::from_utf8(buf).unwrap();
              return ret;
          }
      }
}
#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new System.IO.StreamReader(@"..\..\..\in"));
            Console.SetOut(new System.IO.StreamWriter(@"..\..\..\out"));
            for (int testN = 0; testN < 3; testN++)
            {
#endif
                //SetCulture();
                var r = NextInt();
                var c = NextInt();
                int[,] m = new int[r, c];
                bool[,] intr = new bool[r, c];
                int res = 0;
                int i0= 0, j0=0, ie=0, je=0;
                for (int i = 0; i < r; i++)
                {
                    var s = Console.ReadLine();
                    for (int j = 0; j < c; j++)
                    {
                        if (s[j] == 'T')
                        {
                            m[i, j] = -1;
                            intr[i, j] = true;
                        }
                        else if (s[j] == 'S')
                        {
                            i0 = i;
                            j0 = j;
                        }
                        else if (s[j] == 'E')
                        {
                            ie = i;
                            je = j;
                        }
                        else
                        {
                            m[i, j] = int.Parse(s[j].ToString());
                        }
                    }
                }
                int[,] q2 = new int[r * c * 10, 3];
                int ql = 0;
                int qr = 0;
                q2[qr, 0] = ie; q2[qr, 1] = je; qr++;
                int l = int.MaxValue;
                bool ok = false;
                int x, y;
                while (ql < qr)
                {
                    y = q2[ql, 0];
                    x = q2[ql, 1];
                    int li = q2[ql, 2];
                    if (!intr[y, x] && li <= l)
                    {
                        intr[y, x] = true;
                        if (m[y, x] > 0)
                        {
                            res += m[y, x];
                        }
                        if (y > 0 && !intr[y-1, x] && li + 1 <= l)
                        {
                            q2[qr, 0] = y - 1; q2[qr, 1] = x; q2[qr, 2] = li + 1; qr++;
                        }
                        if (y + 1 < r && !intr[y + 1, x] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y + 1; q2[qr, 1] = x; q2[qr, 2] = li + 1; qr++;
                        }
                        if (x > 0 && !intr[y, x - 1] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y; q2[qr, 1] = x - 1; q2[qr, 2] = li + 1; qr++;
                        }
                        if (x + 1 < c && !intr[y, x + 1] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y; q2[qr, 1] = x + 1; q2[qr, 2] = li + 1; qr++;
                        }
                        if (y == i0 && x == j0)
                        {
                            l = li;
                        }
                    }
                    ql++;
                }
                Console.WriteLine(res);
                //Console.WriteLine(string.Format(NumberFormatInfo.InvariantInfo, "{0:F4}", res));
#if !ONLINE_JUDGE
                Console.WriteLine();
                Console.ReadLine();
            }
            Console.In.Close();
            Console.Out.Close();
#endif
        }

        private static char[] _defaultSplitter = new char[] { ' ', '\t' };

        private static void SetCulture()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        }

        private static char[] ReadChars(int n)
        {
            char[] buffer = new char[n];
            Console.In.ReadBlock(buffer, 0, n);
            return buffer;
        }

        private static string[] ReadAll()
        {
            return Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords()
        {
            return ReadWords(_defaultSplitter);
        }

        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static int[] ReadInts(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        private static int[] ReadInts()
        {
            return ReadInts(_defaultSplitter);
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), NumberFormatInfo.InvariantInfo);
        }

        private static int _pos = 0;
        private static string[] _inputLine = new string[0];

        private static void CheckInputLine()
        {
            if (_pos >= _inputLine.Length)
            {
                _inputLine = ReadWords();
                _pos = 0;
            }
        }

        private static string NextWord()
        {
            CheckInputLine();
            return _inputLine[_pos++];
        }

        private static int NextInt()
        {
            CheckInputLine();
            return int.Parse(_inputLine[_pos++]);
        }

        private static long NextLong()
        {
            CheckInputLine();
            return long.Parse(_inputLine[_pos++]);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new System.IO.StreamReader(@"..\..\..\in"));
            Console.SetOut(new System.IO.StreamWriter(@"..\..\..\out"));
            for (int testN = 0; testN < 3; testN++)
            {
#endif
                //SetCulture();
                var r = NextInt();
                var c = NextInt();
                int[,] m = new int[r, c];
                bool[,] intr = new bool[r, c];
                int res = 0;
                int i0= 0, j0=0, ie=0, je=0;
                int k = 10000;
                for (int i = 0; i < r; i++)
                {
                    var s = Console.ReadLine();
                    for (int j = 0; j < c; j++)
                    {
                        if (s[j] == 'T')
                        {
                            m[i, j] = -1;
                            intr[i, j] = true;
                        }
                        else if (s[j] == 'S')
                        {
                            i0 = i;
                            j0 = j;
                        }
                        else if (s[j] == 'E')
                        {
                            ie = i;
                            je = j;
                        }
                        else
                        {
                            m[i, j] = int.Parse(s[j].ToString());
                        }
                    }
                }
                int[,] q2 = new int[r * c + 2, 3];
                int ql = 0;
                int qr = 0;
                //Queue<int> q = new Queue<int>();
                //q.Enqueue(ie * k + je);
                q2[qr, 0] = ie; q2[qr, 1] = je; qr++;
                int l = int.MaxValue;
                bool ok = false;
                int x, y;
                while (ql < qr)
                {
                    //int v = q.Dequeue();
                    y = q2[ql, 0];
                    x = q2[ql, 1];
                    int li = q2[ql, 2];
                    if (!intr[y, x] && li <= l)
                    {
                        intr[y, x] = true;
                        if (m[y, x] > 0)
                        {
                            res += m[y, x];
                        }
                        if (y > 0 && !intr[y-1, x] && li + 1 <= l)
                        {
                            q2[qr, 0] = y - 1; q2[qr, 1] = x; q2[qr, 2] = li + 1; qr++;
                        }
                        if (y + 1 < r && !intr[y + 1, x] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y + 1; q2[qr, 1] = x; q2[qr, 2] = li + 1; qr++;
                        }
                        if (x > 0 && !intr[y, x - 1] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y; q2[qr, 1] = x - 1; q2[qr, 2] = li + 1; qr++;
                        }
                        if (x + 1 < c && !intr[y, x + 1] && !ok && li + 1 <= l)
                        {
                            q2[qr, 0] = y; q2[qr, 1] = x + 1; q2[qr, 2] = li + 1; qr++;
                        }
                        if (y == i0 && x == j0)
                        {
                            l = li;
                        }
                    }
                    ql++;
                }
                Console.WriteLine(res);
                //Console.WriteLine(string.Format(NumberFormatInfo.InvariantInfo, "{0:F4}", res));
#if !ONLINE_JUDGE
                Console.WriteLine();
                Console.ReadLine();
            }
            Console.In.Close();
            Console.Out.Close();
#endif
        }

        private static char[] _defaultSplitter = new char[] { ' ', '\t' };

        private static void SetCulture()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        }

        private static char[] ReadChars(int n)
        {
            char[] buffer = new char[n];
            Console.In.ReadBlock(buffer, 0, n);
            return buffer;
        }

        private static string[] ReadAll()
        {
            return Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords()
        {
            return ReadWords(_defaultSplitter);
        }

        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static int[] ReadInts(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        private static int[] ReadInts()
        {
            return ReadInts(_defaultSplitter);
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), NumberFormatInfo.InvariantInfo);
        }

        private static int _pos = 0;
        private static string[] _inputLine = new string[0];

        private static void CheckInputLine()
        {
            if (_pos >= _inputLine.Length)
            {
                _inputLine = ReadWords();
                _pos = 0;
            }
        }

        private static string NextWord()
        {
            CheckInputLine();
            return _inputLine[_pos++];
        }

        private static int NextInt()
        {
            CheckInputLine();
            return int.Parse(_inputLine[_pos++]);
        }

        private static long NextLong()
        {
            CheckInputLine();
            return long.Parse(_inputLine[_pos++]);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;

namespace codeforces {
	class Solver {
		//private readonly StreamReader reader = new StreamReader("input.txt");
		//private readonly StreamWriter writer = new StreamWriter("output.txt");
		//private readonly StreamReader reader = new StreamReader("cars.in");
		//private readonly StreamWriter writer = new StreamWriter("cars.out");

		private const int MAX_N = 1010;
		private const long MOD = (long)1e9 + 7;
		private const double EPS = 1e-7;

		private int n, m;
		private int startX, startY, endX, endY;
		private bool[,] was = new bool[MAX_N, MAX_N];
		private char[,] map = new char[MAX_N, MAX_N];
		private Queue<Tuple<int, int>> q = new Queue<Tuple<int, int>>();
		private int[,] d = new int[MAX_N, MAX_N];
		private int[] dx = new int[4] { -1, 1, 0, 0 };
		private int[] dy = new int[4] { 0, 0, -1, 1 };

		public bool Check(int x, int y) {
			return x > 0 && x <= n && y > 0 && y <= m;
		}

		public void Bfs(int sx, int sy) {
			q.Enqueue(Tuple.Create(sx, sy));
			was[sx, sy] = true;
			while (q.Count > 0) {
				Tuple<int, int> t = q.Peek();
				q.Dequeue();
				for (int i = 0; i < 4; i++) {
					int newX = t.Item1 + dx[i], newY = t.Item2 + dy[i];
					if (Check(newX, newY)) {
						if (!was[newX, newY] && map[newX, newY] != 'T') {
							was[newX, newY] = true;
							q.Enqueue(Tuple.Create(newX, newY));
							d[newX, newY] = d[t.Item1, t.Item2] + 1;
						}
					}
				}
			}

		}

		public void SolveTask() {
			var s = Console.ReadLine().Split(' ');
			n = int.Parse(s[0]);
			m = int.Parse(s[1]);
			for (int i = 1; i <= n; i++) {
				var str = Console.ReadLine();
				for (int j = 1; j <= m; j++) {
					d[i, j] = 0;
					was[i, j] = false;
					map[i, j] = str[j - 1];
					if (map[i, j] == 'S') {
						startX = i;
						startY = j;
					}
					if (map[i, j] == 'E') {
						endX = i;
						endY = j;
					}
				}
			}

			Bfs(endX, endY);
			int ans = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					if (map[i, j] != 'T' && map[i, j] != 'S' && map[i, j] != 'E' && was[i, j]) {
						if (d[i, j] <= d[startX, startY]) {
							ans += int.Parse(map[i, j].ToString());
						}
					}
				}
			}

			Console.WriteLine(ans);
		}

		/*
		public void CloseFiles() {
			reader.Close();
			writer.Close();
		}
		*/

	}

	class Program {
		static void Main(string[] args) {
			Solver solver = new Solver();
			solver.SolveTask();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;

namespace codeforces {
	class Solver {
		//private readonly StreamReader reader = new StreamReader("input.txt");
		//private readonly StreamWriter writer = new StreamWriter("output.txt");
		//private readonly StreamReader reader = new StreamReader("cars.in");
		//private readonly StreamWriter writer = new StreamWriter("cars.out");

		private const int MAX_N = 1010;
		private const long MOD = (long)1e9 + 7;
		private const double EPS = 1e-7;

		private int n, m;
		private int startX, startY, endX, endY;
		private bool[,] was = new bool[MAX_N, MAX_N];
		private char[,] map = new char[MAX_N, MAX_N];
		private Queue<Tuple<int, int>> q = new Queue<Tuple<int, int>>();
		private int[,] d = new int[MAX_N, MAX_N];
		private int[] dx = new int[4] { -1, 1, 0, 0 };
		private int[] dy = new int[4] { 0, 0, -1, 1 };

		public bool Check(int x, int y) {
			return x > 0 && x <= n && y > 0 && y <= m;
		}

		public void Bfs(int sx, int sy) {
			q.Enqueue(Tuple.Create(sx, sy));
			was[sx, sy] = true;
			while (q.Count > 0) {
				Tuple<int, int> t = q.Peek();
				q.Dequeue();
				for (int i = 0; i < 4; i++) {
					int newX = t.Item1 + dx[i], newY = t.Item2 + dy[i];
					if (Check(newX, newY)) {
						if (!was[newX, newY] && map[newX, newY] != 'T') {
							was[newX, newY] = true;
							q.Enqueue(Tuple.Create(newX, newY));
							d[newX, newY] = d[t.Item1, t.Item2] + 1;
						}
					}
				}
			}

		}

		public void SolveTask() {
			var s = Console.ReadLine().Split(' ');
			n = int.Parse(s[0]);
			m = int.Parse(s[1]);
			for (int i = 1; i <= n; i++) {
				var str = Console.ReadLine();
				for (int j = 1; j <= m; j++) {
					d[i, j] = 0;
					was[i, j] = false;
					map[i, j] = str[j - 1];
					if (map[i, j] == 'S') {
						startX = i;
						startY = j;
					}
					if (map[i, j] == 'E') {
						endX = i;
						endY = j;
					}
				}
			}

			Bfs(endX, endY);
			int ans = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					if (map[i, j] != 'T' && map[i, j] != 'S' && map[i, j] != 'E') {
						if (d[i, j] <= d[startX, startY]) {
							ans += int.Parse(map[i, j].ToString());
						}
					}
				}
			}

			Console.WriteLine(ans);
		}

		/*
		public void CloseFiles() {
			reader.Close();
			writer.Close();
		}
		*/

	}

	class Program {
		static void Main(string[] args) {
			Solver solver = new Solver();
			solver.SolveTask();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeForces.Solutions.c329_192_1
{
	public class Program2
	{
		private static bool[,] isInQ;
		private static SortedSet<MyPoint> q;
		private static int[,] minMoves;
		private static int nr;
		private static int nc;
		private static string[] f;

		public static void Main()
		{
			checked
			{
				var s1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				nr = s1[0];
				nc = s1[1];

				f = new string[nr];
				int sr = - 1, sc = -1;
				int er = -1, ec = -1;
				for (var y = 0; y < nr; y++)
				{
					f[y] = Console.ReadLine();

					for (var x = 0; x < nc; x++)
					{
						if (f[y][x] == 'S')
						{
							sr = y;
							sc = x;
						}
						if (f[y][x] == 'E')
						{
							er = y;
							ec = x;
						}
					}
				}

				minMoves = new int[nr,nc];
				for (var y = 0; y < nr; y++)
					for (var x = 0; x < nc; x++)
						minMoves[y, x] = int.MaxValue;

				isInQ = new bool[nr,nc];
				q = new SortedSet<MyPoint>();
				CheckPoint(er, ec, 0);

				while (q.Count > 0)
				{
					var p = q.Min;
					q.Remove(p);
					var y = p.Y;
					var x = p.X;
					CheckPoint(y, x, p.V);
				}

				var myMoves = minMoves[sr, sc];
				var res = 0;
				for (var y = 0; y < nr; y++)
					for (var x = 0; x < nc; x++)
						if (char.IsDigit(f[y], x) && minMoves[y, x] <= myMoves)
						{
							res += f[y][x] - '0';
						}

				Console.WriteLine(res);
			}
		}

		class MyPoint : IComparable<MyPoint>
		{
			public int X;
			public int Y;
			public int V;

			public MyPoint(int y, int x, int v)
			{
				X = x;
				Y = y;
				V = v;
			}

			public int CompareTo(MyPoint other)
			{
				int r;
				r = V.CompareTo(other.V);
				if (r != 0) return r;
				r = X.CompareTo(other.X);
				if (r != 0) return r;
				r = Y.CompareTo(other.Y);
				if (r != 0) return r;
				return 0;
			}
		}

		private static int GetVal(int y, int x)
		{
			if (y < 0 || x < 0 || y >= nr || x >= nc) return int.MaxValue;
			return minMoves[y, x];
		}

		private static void CheckPoint(int y, int x, int  v)
		{
			minMoves[y, x] = v;
			ConsiderPoint(y + 1, x, minMoves[y, x] + 1);
			ConsiderPoint(y - 1, x, minMoves[y, x] + 1);
			ConsiderPoint(y, x - 1, minMoves[y, x] + 1);
			ConsiderPoint(y, x + 1, minMoves[y, x] + 1);
		}

		private static void ConsiderPoint(int y, int x, int v)
		{
			if (y < 0 || x < 0 || y >= nr || x >= nc) return;
			if (f[y][x] == 'T') return;

			if (minMoves[y,x] > v)
			{
				q.Add(new MyPoint(y, x, v));
				isInQ[y, x] = true;
			}
		}

		private static void AddToQ(int y, int x)
		{
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeForces.Solutions.c329_192_1
{
	public class Program2
	{
		private static bool[,] isInQ;
		private static List<Tuple<int, int>> q;
		private static int[,] minMoves;
		private static int nr;
		private static int nc;
		private static string[] f;

		public static void Main()
		{
			checked
			{
				var s1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				nr = s1[0];
				nc = s1[1];

				f = new string[nr];
				int sr = - 1, sc = -1;
				int er = -1, ec = -1;
				for (var y = 0; y < nr; y++)
				{
					f[y] = Console.ReadLine();

					for (var x = 0; x < nc; x++)
					{
						if (f[y][x] == 'S')
						{
							sr = y;
							sc = x;
						}
						if (f[y][x] == 'E')
						{
							er = y;
							ec = x;
						}
					}
				}

				minMoves = new int[nr,nc];
				for (var y = 0; y < nr; y++)
					for (var x = 0; x < nc; x++)
						minMoves[y, x] = int.MaxValue;

				isInQ = new bool[nr,nc];
				q = new List<Tuple<int, int>>(1000);

				minMoves[er, ec] = 0;
				CheckPoint(er, ec);

				while (q.Count > 0)
				{
					var p = q[q.Count - 1];
					q.RemoveAt(q.Count - 1);
					var y = p.Item1;
					var x = p.Item2;
					isInQ[y, x] = false;
					CheckPoint(y, x);
				}

				var myMoves = minMoves[sr, sc];
				var res = 0;
				for (var y = 0; y < nr; y++)
					for (var x = 0; x < nc; x++)
						if (char.IsDigit(f[y], x) && minMoves[y, x] <= myMoves)
						{
							res += f[y][x] - '0';
						}

				Console.WriteLine(res);
			}
		}

		private static int GetVal(int y, int x)
		{
			if (y < 0 || x < 0 || y >= nr || x >= nc) return int.MaxValue;
			return minMoves[y, x];
		}

		private static void CheckPoint(int y, int x)
		{
			ConsiderPoint(y + 1, x, minMoves[y, x] + 1);
			ConsiderPoint(y - 1, x, minMoves[y, x] + 1);
			ConsiderPoint(y, x - 1, minMoves[y, x] + 1);
			ConsiderPoint(y, x + 1, minMoves[y, x] + 1);
		}

		private static void ConsiderPoint(int y, int x, int v)
		{
			if (y < 0 || x < 0 || y >= nr || x >= nc) return;
			if (f[y][x] == 'T') return;

			if (minMoves[y,x] > v)
			{
				minMoves[y, x] = v;
				AddToQ(y, x);
			}
		}

		private static void AddToQ(int y, int x)
		{
			if (isInQ[y, x]) return;
			q.Add(Tuple.Create(y, x));
			isInQ[y, x] = true;
		}
	}
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Biridian_Forest
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static Queue<Tuple<int, int>> q;
        private static int[][] nn;

        private static void Main(string[] args)
        {
            int r = Next();
            int c = Next();

            nn = new int[r + 2][];
            nn[0] = new int[c + 2];
            nn[r + 1] = new int[c + 2];
            for (int i = 0; i < c + 2; i++)
            {
                nn[0][i] = -1;
                nn[r + 1][i] = -1;
            }

            var list = new List<Tuple<int, int, int>>();

            q = new Queue<Tuple<int, int>>();
            int x = 0, y = 0, sx = 0, sy = 0;
            for (int i = 1; i <= r; i++)
            {
                nn[i] = new int[c + 2];
                nn[i][0] = -1;
                nn[i][c + 1] = -1;
                for (int j = 1; j <= c; j++)
                {
                    int p = Next(true);
                    if (p > 0)
                    {
                        if (p == 10)
                        {
                            x = i;
                            y = j;
                        }
                        else if (p == 11)
                        {
                            nn[i][j] = 1;
                            q.Enqueue(new Tuple<int, int>(i, j));
                        }
                        else
                        {
                            list.Add(new Tuple<int, int, int>(i, j, p));
                        }
                    }
                    else if (p < 0)
                    {
                        nn[i][j] = p;
                    }
                }
            }

            while (q.Count > 0)
            {
                Tuple<int, int> t = q.Dequeue();
                Add(nn[t.Item1][t.Item2], t.Item1 + 1, t.Item2);
                Add(nn[t.Item1][t.Item2], t.Item1 - 1, t.Item2);
                Add(nn[t.Item1][t.Item2], t.Item1, t.Item2 - 1);
                Add(nn[t.Item1][t.Item2], t.Item1, t.Item2 + 1);
            }

            int max = nn[x][y];

            int count = 0;
            foreach (var tuple in list)
            {
                if (nn[tuple.Item1][tuple.Item2] <= max)
                    count += tuple.Item3;
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static void Add(int from, int i, int j)
        {
            if (nn[i][j] == 0)
            {
                nn[i][j] = from + 1;
                q.Enqueue(new Tuple<int, int>(i, j));
            }
        }

        private static int Next(bool one = false)
        {
            int c;
            do
            {
                c = reader.Read();
                if (c == 'T')
                    return -1;
                if (c == 'S')
                    return 10;
                if (c == 'E')
                    return 11;
            } while (c < '0' || c > '9');
            int res = c - '0';
            if (one)
                return res;
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Biridian_Forest
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static Queue<Tuple<int, int>> q;
        private static int[][] nn;

        private static void Main(string[] args)
        {
            int r = Next();
            int c = Next();

            nn = new int[r + 2][];
            nn[0] = new int[c + 2];
            nn[r + 1] = new int[c + 2];
            for (int i = 0; i < c + 2; i++)
            {
                nn[0][i] = -1;
                nn[r + 1][i] = -1;
            }

            var list = new List<Tuple<int, int, int>>();

            q = new Queue<Tuple<int, int>>();
            int x = 0, y = 0, sx = 0, sy = 0;
            for (int i = 1; i <= r; i++)
            {
                nn[i] = new int[c + 2];
                nn[i][0] = -1;
                nn[i][c + 1] = -1;
                for (int j = 1; j <= c; j++)
                {
                    int p = Next(true);
                    if (p > 0)
                    {
                        if (p == 10)
                        {
                            x = i;
                            y = j;
                        }
                        else if (p == 11)
                        {
                            nn[i][j] = 1;
                            q.Enqueue(new Tuple<int, int>(i, j));
                        }
                        else
                        {
                            list.Add(new Tuple<int, int, int>(i, j, p));
                        }
                    }
                    else if (p < 0)
                    {
                        nn[i][j] = p;
                    }
                }
            }

            while (q.Count > 0)
            {
                Tuple<int, int> t = q.Dequeue();
                Add(nn[t.Item1][t.Item2], t.Item1 + 1, t.Item2);
                Add(nn[t.Item1][t.Item2], t.Item1 - 1, t.Item2);
                Add(nn[t.Item1][t.Item2], t.Item1, t.Item2 - 1);
                Add(nn[t.Item1][t.Item2], t.Item1, t.Item2 + 1);
            }

            int max = nn[x][y];

            int count = 0;
            foreach (var tuple in list)
            {
                if (nn[tuple.Item1][tuple.Item2] != 0 && nn[tuple.Item1][tuple.Item2] <= max)
                    count += tuple.Item3;
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static void Add(int from, int i, int j)
        {
            if (nn[i][j] == 0)
            {
                nn[i][j] = from + 1;
                q.Enqueue(new Tuple<int, int>(i, j));
            }
        }

        private static int Next(bool one = false)
        {
            int c;
            do
            {
                c = reader.Read();
                if (c == 'T')
                    return -1;
                if (c == 'S')
                    return 10;
                if (c == 'E')
                    return 11;
            } while (c < '0' || c > '9');
            int res = c - '0';
            if (one)
                return res;
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


#include<stdio.h>
int main()
{
    int q,n,k,a,t,b,i,o=0;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&n,&k);
        for(i=0; i<n; i++)
        {
            scanf("%d",&a);
            if(a&1)
                o++,t=i+1;
        }
        if(o<k||((k+o)&1))
            printf("NO\n");
        else
        {
            printf("YES\n");
            printf("%d\n",t);
        }
        o=0;
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long q,a,b,c;
    scanf("%lld",&q);
    while(q--)
    {
        scanf("%lld%lld%lld",&a,&b,&c);
        printf("%lld\n",(a+b+c)/2);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long t,n,k,a[200000],b,i,o=0;
    scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld%lld",&n,&k);
        for(i=0; i<n; i++)
        {
            scanf("%lld",&a[i]);
            if(a[i]&1)
                o++;
        }
        if(o<k||(k+o)&1)
            printf("NO\n");
        else
        {
            printf("YES\n");
            for(i=0; i<n; i++)
                if((a[i])&1)
                {
                    printf("%lld\n",i+1);
                    break;
                }
        }
        o=0;
    }
    return 0;
}


#include<stdio.h>
#define TAM 200001

int main(){
	int q, n, k, a, cont, impar[TAM];

	scanf("%d", &q);
	while(q--){
		scanf("%d%d", &n, &k);

		cont = 0;
		for(int i=1; i<=n; i++){
			scanf("%d", &a);
			if(a%2)
				impar[cont++] = i;
		}

		if(cont<k||(k%2 && cont%2==0)||(k%2==0 && cont%2)){
			printf("NO\n");
			continue;
		}

		printf("YES\n");
		for(int i=0; i<k-1; i++)
			printf("%d ", impar[i]);
		printf("%d\n", n);
	}

	return 0;
}


#include <stdio.h>

int main(void) {
	long long int i,j,q,n,k,a;
	int index[200001],count=0;
	scanf("%lld",&q);

	for(i=0;i<q;i++){
		scanf("%lld %lld",&n,&k);

		count=0;
		for(j=0;j<n;j++){
			scanf("%lld",&a);
			if(a%2==1){
				index[count++]=j+1;
			}
		}

		if(count<k || (count-k)%2==1) printf("NO\n");
		else{
			j=count-k;
			printf("YES\n");
			for(;j<count;j++){
				printf("%d ",index[j]);
			}
			printf("\n");
		}
	}
	return 0;
}


#include <stdio.h>

int main(void) {
	int i,j,q,n,k;
	int index[200001],count=0,a;
	scanf("%d",&q);

	for(i=0;i<q;i++){
		scanf("%d %d",&n,&k);

		count=0;
		for(j=0;j<n;j++){
			scanf("%d",&a);
			if(a%2==1){
				index[count++]=j+1;
			}
		}
		index[count-1]=n;

		if(count<k || (count-k)%2==1) printf("NO\n");
		else{
			j=count-k;
			printf("YES\n");
			for(;j<count;j++){
				printf("%d ",index[j]);
			}
			printf("\n");
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
	unsigned long int q;
	scanf("%ld",&q);
	for (unsigned long int i = 0; i < q; ++i)
	{
		unsigned long int count_odd = 0;
		unsigned long int indexer = 0;
		unsigned long int n,k;
		scanf("%ld %ld",&n,&k);
		unsigned long long int arr[n];
		int arr2[n];
		for (unsigned long int i = 0; i < n; ++i)
		{
			scanf("%I64d",&arr[i]);
		}

		if (k == 1)
		{
			for (unsigned long int i = 0; i < n; ++i)
			{
				if (arr[i]%2 != 0)
				{
					count_odd ++;
				}
			}
			if (count_odd %2 == 0)
			{
				printf("NO\n");
			}
			else
			{
				printf("YES\n");
				printf("%ld\n",n);
			}
			continue;
		}
		else
		{
			for (unsigned long int i = 0; i < n; ++i)
			{
				if (arr[i]%2 != 0)
				{
					count_odd ++;
				}
			}
		}

		if ((count_odd >= k) && (count_odd - k) % 2 == 0)
		{
			printf("YES\n");
			//printf("%ld %ld\n",count_odd,k);
		}
		else
		{
			printf("NO\n");
			//printf("%ld %ld\n",count_odd,k);
			continue;
		}

		for (unsigned long int i = 0; i < n; ++i)
		{
				if (arr[i] %2 != 0)
				{
					printf("%ld ",i+1);
					indexer++;
				}
			if (indexer == k-1 )
			{
				break;
			}
		}

		printf("%ld\n",n);
	}
	return 0;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
    int n,k,od=0;
    scanf("%d%d",&n,&k);
    int ar[n];
    for(int i=0;i<n;i++)
    {
    scanf("%d",&ar[i]);
    if(ar[i]%2!=0)
    od++;
    }
    if(k==1)
    {
    if(od%2!=0)
    printf("YES\n%d\n",n);
    else
    printf("NO\n");
    }
    else
    {
    int cnt=0;
    if(od==k)
    {
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else if(od>k)
    {
    int l=0,odcnt=0;
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    l=i;
    cnt++;
    }
    }
    for(int i=l+1;i<n;i++)
    {
    if(ar[i]%2!=0)
    odcnt++;
    }
    if(odcnt%2!=0)
    {
    cnt=0;
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else
    printf("NO\n");
    }
    else
    printf("NO\n");
    }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int t, m;
    scanf("%d",&t);
    m=t-1;
    int **arr, check[t];
    arr=(int **)malloc(t*sizeof(int *));
    /*for(int i=0;i<t;i++)
    {
    for(int j=0;j<200001;j++)
    arr[i][j]=0;
    }*/
    while(t--)
    {
    int n,k,odd=0,z=1;
    scanf("%d%d",&n,&k);
    int ar[n];
    for(int i=0;i<n;i++)
    {
    scanf("%d",&ar[i]);
    if(ar[i]%2!=0)
    odd++;
    }
    if(odd<k)
    check[t]=-1;
    else if(odd==k)
    {
    arr[t]=(int *)malloc((k+1)*sizeof(int ));
    check[t]=1;
    for(int i=0;i<n;i++)
    {
    if(ar[i]%2!=0)
    arr[t][z++]=i+1;
    }
    arr[t][0]=z;
    }

    else
    {
    if(k%2==0)
    {
    if(odd%2!=0)
    check[t]=-1;
    else
    {
    arr[t]=(int *)malloc((k+1)*sizeof(int ));
    for(int i=0;z<k;i++)
    {
    if(ar[i]%2!=0)
    arr[t][z++]=i+1;
    }
    arr[t][z++]=n;
    arr[t][0]=z;
    }

    }

    else
    {
    if(odd%2==0)
    check[t]=-1;
    else
    {
    arr[t]=(int *)malloc((k+1)*sizeof(int ));
    for(int i=0;z<k;i++)
    {
    if(ar[i]%2!=0)
    arr[t][z++]=i+1;
    }
    arr[t][z++]=n;
    arr[t][0]=z;
    }
    }
    }
    }
    for(int i=m;i>=0;i--)
    {
    if(check[i]==-1)
    printf("%s\n","NO");
    else if(check[i]==1)
    {
    printf("%s\n","YES");
    for(int j=1;j<arr[i][0];j++)
    printf("%d ",arr[i][j]);
    printf("\n");
    }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
    int n,k,od=0;
    scanf("%d%d",&n,&k);
    int ar[n];
    for(int i=0;i<n;i++)
    {
    scanf("%d",&ar[i]);
    if(ar[i]%2!=0)
    od++;
    }
    int cnt=0;
    if(od==k)
    {
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else if(od>k)
    {
    int l=0,odcnt=0;
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    l=i;
    cnt++;
    }
    }
    for(int i=l+1;i<n;i++)
    {
    if(ar[i]%2!=0)
    odcnt++;
    }
    if(odcnt%2!=0)
    {
    cnt=0;
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else
    printf("NO\n");
    }
    else
    printf("NO\n");
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
    int n,k,od=0;
    scanf("%d%d",&n,&k);
    int ar[n];
    for(int i=0;i<n;i++)
    {
    scanf("%d",&ar[i]);
    if(ar[i]%2!=0)
    od++;
    }
    int cnt=0;
    if(od==k)
    {
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else if(od>k)
    {
    int l=0,odcnt=0;
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    l=i;
    cnt++;
    }
    }
    for(int i=l;i<n;i++)
    {
    if(ar[i]%2!=0)
    odcnt++;
    }
    if(odcnt%2!=0)
    {
    cnt=0;
    printf("YES\n");
    for(int i=0;i<n&&cnt<k-1;i++)
    {
    if(ar[i]%2!=0)
    {
    cnt++;
    printf("%d ",i+1);
    }
    }
    printf("%d\n",n);
    }
    else
    printf("NO\n");
    }
    else
    printf("NO\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
	long int T,n,i,j,k,l,Sum=0,c;
	scanf("%ld",&T);
    for(i=0;i<T;i++)
	{
		c=0;
	scanf("%ld",&n);
	scanf("%ld",&k);
	long int ar[n];
	long int br[n];
	for(j=0;j<n;j++)
	{
		scanf("%ld",&ar[j]);
			if(c==k-1)
		{
			Sum=Sum+ar[j];
			continue;
		}
		Sum=Sum+ar[j];

		if(Sum%2!=0)
		{
			br[c]=j;
			c++;
			Sum=0;
		}

	}
		if(Sum%2!=0)
		{
			br[c]=n-1;
			c++;
			Sum=0;
		}
	if(c==k)
	{
		printf("YES\n");
		for(j=0;j<c;j++)
		{
			printf("%ld ",br[j]+1);
		}
	}
	else
	printf("NO\n");
	}
}


#include <stdio.h>
typedef long long ll;
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll MOD = 100000;

int n,t,k;
int a[202020],cnt[202020]={0};

int solve(){
    int ans = 0;
    int odd = 0;
    rep(i,n)
        if(a[i]%2)
            odd++;

    if((odd%2) != (k%2)) ans = 0;
    else ans = 1;

    return ans;
}

int main(){
    scanf("%d", &t);
    rep(tes,t){
        scanf("%d", &n);
        scanf("%d", &k);
        rep(i,n) scanf("%d", a+i);
        if(solve()){
            puts("YES");
            rep(j,n){
                if(k <= 1) break;
                if(a[j]%2) {
                    printf("%d ",j+1);
                    k--;
                }
            }
            printf("%d\n",n);
        }else puts("NO");
    }
}


#include <stdio.h>
typedef long long ll;
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll MOD = 100000;

int n,t,k;
int a[202020],cnt[202020]={0};

int solve(){
    int ans = 0;
    int odd = 0;
    rep(i,n)
        if(a[i]%2)
            odd++;

    if((odd%2) != (k%2)) ans = 0;
    else ans = 1;

    return ans;
}

int main(){
    scanf("%d", &t);
    rep(i,t){
        scanf("%d", &n);
        scanf("%d", &k);
        rep(i,n) scanf("%d", a+i);
        if(solve()){
            puts("YES");
            rep(j,n){
                if(k <= 1) break;
                if(a[j]%2) {
                    printf("%d ",j+1);
                    k--;
                }
            }
            printf("%d\n",n);
        }else puts("NO");
    }
}


#include <stdio.h>
typedef long long ll;
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int n,t,k;
int a[202020];

int solve(){
    int ans = 0;
    int odd = 0;
    rep(i,n)
        if(a[i]%2)
            odd++;

    if((odd%2) != (k%2) || odd < k) ans = 0;
    else ans = 1;

    return ans;
}

int main(){
    scanf("%d", &t);
    rep(tes,t){
        scanf("%d", &n);
        scanf("%d", &k);
        rep(i,n) scanf("%d", a+i);
        if(solve()){
            puts("YES");
            rep(j,n){
                if(k <= 1) break;
                if(a[j]%2) {
                    printf("%d ",j+1);
                    k--;
                }
            }
            printf("%d\n",n);
        }else puts("NO");
    }
}


#include <stdio.h>
#define READ(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)
#define FOR(i,L,R) for (int i = L; i < R; i++)

int main(){
    READ(q);
    while(q--){
        READ(n); READ(k);
        int arr[n], oddCnt = 0;
        FOR(i, 0, n){
            READ(a);
            arr[i] = a % 2;
            if (arr[i] == 1)
                oddCnt++;
        }

        if (oddCnt % 2 != k % 2 || oddCnt < k){
            printf("NO\n");
            continue;
        } else {
            printf("YES\n");
            FOR(i, 0, n){
                if (i == n - 2 && arr[i] == 1 && arr[n - 1] == 0)
                    printf("%d ", i + 2);
                else if (arr[i] == 1)
                    printf("%d ", i + 1);
            }
            printf("\n");
        }
    }
}


#include <stdio.h>
#define READ(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)
#define FOR(i,L,R) for (int i = L; i < R; i++)

int main(){
    READ(q);
    while(q--){
        READ(n); READ(k);
        int arr[n], oddCnt = 0;
        FOR(i, 0, n){
            READ(a);
            arr[i] = a % 2;
            if (arr[i] == 1)
                oddCnt++;
        }

        if (oddCnt % 2 != k % 2 || oddCnt < k){
            printf("NO\n");
            continue;
        } else {
            printf("YES\n");
            FOR(i, 0, n){
                if (k == 1){
                    printf("%d ", n);
                    break;
                }
                else if (arr[i] == 1){
                    printf("%d ", i + 1);
                    k--;
                }
            }
            printf("\n");
        }
    }
}


#include <stdio.h>
#define READ(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)
#define FOR(i,L,R) for (int i = L; i < R; i++)

int main(){
    READ(q);
    while(q--){
        READ(n); READ(k);
        int arr[n], oddCnt = 0;
        FOR(i, 0, n){
            READ(a);
            arr[i] = a % 2;
            if (arr[i] == 1)
                oddCnt++;
        }

        if (oddCnt % 2 != k % 2 || oddCnt < k){
            printf("NO\n");
            continue;
        } else {
            printf("YES\n");
            FOR(i, 0, n){
                if (arr[i] == 1)
                    printf("%d ", i + 1);
            }
            printf("\n");
        }
    }
}


#include<stdio.h>

int main(){
  int t;
  scanf("%d", &t);
  while(t--){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    int b[n];
    int count = 0;
    for(int i=0; i<n; i++){
      scanf("%d", &a[i]);
      if(a[i]%2 == 1){
        b[count] = i;
        count++;
      }
    }
    if(count >=k && k%2 == count%2){
      printf("YES\n");
      int iter = count/k;
      for(int j = 0; j<count; j=j+iter){
        if(j+iter>=count){
          printf("%d\n", b[j]+1);
        }
        else{
          printf("%d ", b[j]+1);
        }
      }
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}


#include<stdio.h>

int main(){
  int t;
  scanf("%d", &t);
  while(t--){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    int b[n];
    int count = 0;
    for(int i=0; i<n; i++){
      scanf("%d", &a[i]);
      if(a[i]%2 == 1){
        b[count] = i;
        count++;
      }
    }
    if(count >=k && k%2 == count%2){
      printf("YES\n");
      for(int j=0; j<k-1; j++){
        printf("%d ", b[j]+1);
      }
      printf("%d\n", b[count-1]+1);
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}


#include<stdio.h>

int main(){
  int t;
  scanf("%d", &t);
  while(t--){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    int b[n];
    int count = 0;
    for(int i=0; i<n; i++){
      scanf("%d", &a[i]);
      if(a[i]%2 == 1){
        b[count] = i;
        count++;
      }
    }
    if(count >=k && k%2 == count%2){
      printf("YES\n");
      for(int j=0; j<k-1; j++){
        printf("%d ", b[j]+1);
      }
      printf("%d\n", n);
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        console.log(foo(data, k));
        testCount++;
    }
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data) {
        let reserv = 0;
        let result = data.reduce((agr, value) => {
            let str = String(value);
            if (str[str.length - 1] % 2) {
                reserv++;
                value = value - 1;
            }
            return agr + value;
        }, 0);
        let resultArray = String(result / 2).split("");
        let last = +resultArray[resultArray.length - 1] + Math.floor(reserv / 2);
        resultArray.splice(- 1, 1, last);

        return +resultArray.join("");
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount].split(" ").map(Number);
        //console.log(data)
        console.log(foo(data));
        testCount++;
    }
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                //console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        let result = foo(data, k);
        if (result.length !== k) console.log("NO");
        else {
            console.log("YES");
            console.log(result.join(" "));
        }
        testCount++;
    }
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 1;

        while (end < data.length && count <= k) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) answer += "NO\n";
        else {
            answer += "YES\n";
            answer += result.join(" ") + "\n";
        }
        testCount++;
    }
    print(answer);
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                //console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        let result = foo(data, k);
        if (result.length !== k) console.log("NO");
        else result.join(" ");
        testCount++;
    }
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 1;

        while (end < data.length && count <= k) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) answer += "NO\n";
        else {
            answer += "YES\n";
            answer += result.join(" ") + "\n";
        }
        testCount++;
    }
    console.log(answer);
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) console.log("NO");
        else {
            console.log("YES");
            console.log(result.join(" "));
        }
        testCount++;
    }
})


let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 1;

        while (end < data.length && count <= k) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) console.log("NO");
        else {
            console.log("YES");
            console.log(result.join(" "));
        }
        testCount++;
    }
})


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;

namespace Achill
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine()), cur, count;
            List<int> res = new List<int>();
            int[] a;
            int[] nk;
            for (int i = 0; i < q; ++i)
            {
                cur = 0;
                count = 0;
                nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                for(int j = 0; j < nk[0]; ++j)
                {
                    if(cur < nk[1] - 1)
                    {
                        if (a[j] % 2 == 1)
                        {
                            res.Add(j + 1);
                            cur++;
                        }
                    }
                    else
                    {
                        if (a[j] % 2 == 1)
                        {
                            count++;
                        }
                    }
                }
                if(count % 2 == 0 || cur <= nk[1]-2)
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    res.Add(nk[0]);
                    Console.WriteLine("YES");
                    Console.WriteLine(String.Join(" ", res));
                }
                res.Clear();
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;

namespace Achill
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine()), cur, count;
            for (int i = 0; i < q; ++i)
            {
                cur = 0;
                count = 0;
                int[] nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                List<int> res = new List<int>();
                for (int j = 0; j < nk[0]; ++j)
                {
                    if(cur < nk[1] - 1)
                    {
                        if (a[j] % 2 == 1)
                        {
                            res.Add(j + 1);
                            cur++;
                        }
                    }
                    else
                    {
                        if (a[j] % 2 == 1)
                        {
                            count++;
                        }
                    }
                }
                if(count % 2 == 0 || cur <= nk[1]-2)
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    res.Add(nk[0]);
                    Console.WriteLine("YES");
                    Console.WriteLine(String.Join(" ", res));
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;

namespace Achill
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = Int32.Parse(Console.ReadLine()), cur, count;
            List<int> res = new List<int>();
            List<int> a;
            int[] nk;
            for (int i = 0; i < q; ++i)
            {
                cur = 0;
                count = 0;
                nk = Console.ReadLine().Split().Select(item => Int32.Parse(item)).ToArray();
                a = Console.ReadLine().Split().Select(item => Int32.Parse(item)).ToList();
                for(int j = 0; j < nk[0]; ++j)
                {
                    if(cur < nk[1] - 1)
                    {
                        if (a[j] % 2 == 1)
                        {
                            res.Add(j + 1);
                            cur++;
                        }
                    }
                    else
                    {
                        if (a[j] % 2 == 1)
                        {
                            count++;
                        }
                    }
                }
                if(count % 2 == 0 || cur <= nk[1]-2)
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    res.Add(nk[0]);
                    Console.WriteLine("YES");
                    Console.WriteLine(String.Join(" ", res));
                }
                res.Clear();
            }
        }
    }
}