# Path: pypinyin/contrib/tone_convert.py



import re
from pypinyin.contrib.tone_convert import tone_to_tone2, tone2_to_tone
        tone2_pinyin_list = [tone_to_tone2(x[0]) for x in pinyin_list]
        if '3' not in ''.join(tone2_pinyin_list):
            return pinyin_list

        changed = False
        third_num = 0
        for pinyin in tone2_pinyin_list:
            if '3' in pinyin:
                third_num += 1
            else:
                third_num = 0

        if third_num == 2:
            for i, v in enumerate(tone2_pinyin_list):
                if '3' in v:
                    tone2_pinyin_list[i] = v.replace('3', '2')
                    changed = True
                    break

        elif third_num > 2:
            n = 1
            for i, v in enumerate(tone2_pinyin_list):
                if '3' in v:
                    if n == third_num:
                        break
                    tone2_pinyin_list[i] = v.replace('3', '2')
                    changed = True
                    n += 1

        if changed:

# Path: pypinyin/contrib/tone_convert.py



# Path: pypinyin/contrib/tone_sandhi.py
import re
from pypinyin.contrib.tone_convert import tone_to_tone2, tone2_to_tone

        tone2_pinyin_list = [tone_to_tone2(x[0]) for x in pinyin_list]
        if '3' not in ''.join(tone2_pinyin_list):
            return pinyin_list

        changed = False
        third_num = 0
        for pinyin in tone2_pinyin_list:
            if '3' in pinyin:
                third_num += 1
            else:
                third_num = 0

        if third_num == 2:
            for i, v in enumerate(tone2_pinyin_list):
                if '3' in v:
                    tone2_pinyin_list[i] = v.replace('3', '2')
                    changed = True
                    break

        elif third_num > 2:
            n = 1
            for i, v in enumerate(tone2_pinyin_list):
                if '3' in v:
                    if n == third_num:
                        break
                    tone2_pinyin_list[i] = v.replace('3', '2')
                    changed = True
                    n += 1

        if changed:

            return [[tone2_to_tone(x)] for x in tone2_pinyin_list]