using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var r = new Regex("^\\d(\\d|(?<!-)-)*\\d$|^\\d$");
Console.WriteLine(r.IsMatch("1-2-3"));
Console.WriteLine(r.IsMatch("1-222-3333"));
Console.WriteLine(r.IsMatch("123"));
Console.WriteLine(r.IsMatch("1--23"));
Console.WriteLine(r.IsMatch("1-2-3-"));
Console.WriteLine(r.IsMatch("1"));
Console.WriteLine(r.IsMatch("-11-2-3-"));
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CgkJdmFyIHIgPSBuZXcgUmVnZXgoIl5cXGQoXFxkfCg/PCEtKS0pKlxcZCR8XlxcZCQiKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKHIuSXNNYXRjaCgiMS0yLTMiKSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShyLklzTWF0Y2goIjEtMjIyLTMzMzMiKSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShyLklzTWF0Y2goIjEyMyIpKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKHIuSXNNYXRjaCgiMS0tMjMiKSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShyLklzTWF0Y2goIjEtMi0zLSIpKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKHIuSXNNYXRjaCgiMSIpKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKHIuSXNNYXRjaCgiLTExLTItMy0iKSk7Cgl9Cn0=