using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
public const string RefPrefix = "p:";
public static readonly IReadOnlyDictionary<char, int> Symbols = "0123456789abcdefghijklmnopqrstuvwxyz".Select((x, i) => (x, i)).ToDictionary(x => x.x, x => x.i);
public static int? CalculateTermIndex(string base36reference)
if(base36reference.StartsWith(RefPrefix) && base36reference.Length > RefPrefix.Length)
int i = RefPrefix.Length;
while (i < base36reference.Length)
if(!Symbols.TryGetValue(base36reference[i], out int index))
result += (int)Math.Pow(Symbols.Count, base36reference.Length - RefPrefix.Length - 1) * index;