 In the case of "-s", this is from the original initial "s-" of the definite article (Old Irish sin, in), while where "-n" is concerned, this is an extension from prepositions that end in "-n", like Classical Gaelic i/a ""in"", before vowels in/an (Modern Gaelic an and am have become the standard forms except in set phrases such as a-mach ""out(wards)"")