def substrings(a, b, n):
    """Return substrings of length n in both a and b"""
    subs = set()
    if (n > len(a)):
        return subs
    if (a == b and len(a) == n):
        return [a]

    for i in range(0, len(a) - n + 1):
        substring = a[i:i+n]
        if (substring in b):
            subs.add(substring)
    return subs