docs: def _Fierz_to_Bern_III_IV_V(Fqqqq, qqqq):
      """From Fierz to 4-quark Bern basis for Classes III, IV and V.
      `qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
      # 2nd != 4th, color-octet redundant
      if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
          return {
          '1' + qqqq : -Fqqqq['F' + qqqq + '1'] / 3
                          + 4 * Fqqqq['F' + qqqq + '3'] / 3,
          '3' + qqqq : Fqqqq['F' + qqqq + '1'] / 12 - Fqqqq['F' + qqqq + '3'] / 12,
          '5' + qqqq : -Fqqqq['F' + qqqq + '5p'] / 3
                      + 4 * Fqqqq['F' + qqqq + '7p'] / 3,
          '7' + qqqq : Fqqqq['F' + qqqq + '5p'] / 3 - Fqqqq['F' + qqqq + '7p'] / 3
                      + Fqqqq['F' + qqqq + '9p'],
          '9' + qqqq : Fqqqq['F' + qqqq + '5p'] / 48
                       - Fqqqq['F' + qqqq + '7p'] / 48,
  
          '1p' + qqqq : -Fqqqq['F' + qqqq + '1p'] / 3
                        + 4 * Fqqqq['F' + qqqq + '3p'] / 3,
          '3p' + qqqq : Fqqqq['F' + qqqq + '1p'] / 12
                        - Fqqqq['F' + qqqq + '3p'] / 12,
          '5p' + qqqq : -Fqqqq['F' + qqqq + '5'] / 3
                        + 4 * Fqqqq['F' + qqqq + '7'] / 3,
          '7p' + qqqq : Fqqqq['F' + qqqq + '5'] / 3 - Fqqqq['F' + qqqq + '7'] / 3
                        + Fqqqq['F' + qqqq + '9'],
          '9p' + qqqq : Fqqqq['F' + qqqq + '5'] / 48
                        - Fqqqq['F' + qqqq + '7'] / 48
                              }
      if qqqq in ['dbbb', 'sbbb', 'dsss']:  # 2nd = 4th, color-octet redundant
          return {
          '1' + qqqq : -Fqqqq['F' + qqqq + '1'] / 3
                          + 4 * Fqqqq['F' + qqqq + '3'] / 3,
          '3' + qqqq : Fqqqq['F' + qqqq + '1'] / 12 - Fqqqq['F' + qqqq + '3'] / 12,
          '5' + qqqq : -Fqqqq['F' + qqqq + '5'] / 3
                      + 4 * Fqqqq['F' + qqqq + '7'] / 3,
          '7' + qqqq : Fqqqq['F' + qqqq + '5'] / 3 - Fqqqq['F' + qqqq + '7'] / 3
                      + Fqqqq['F' + qqqq + '9'],
          '9' + qqqq : Fqqqq['F' + qqqq + '5'] / 48
                       - Fqqqq['F' + qqqq + '7'] / 48,
  
          '1p' + qqqq : -Fqqqq['F' + qqqq + '1p'] / 3
                        + 4 * Fqqqq['F' + qqqq + '3p'] / 3,
          '3p' + qqqq : Fqqqq['F' + qqqq + '1p'] / 12
                        - Fqqqq['F' + qqqq + '3p'] / 12,
          '5p' + qqqq : -Fqqqq['F' + qqqq + '5p'] / 3
                        + 4 * Fqqqq['F' + qqqq + '7p'] / 3,
          '7p' + qqqq : Fqqqq['F' + qqqq + '5p'] / 3 - Fqqqq['F' + qqqq + '7p'] / 3
                        + Fqqqq['F' + qqqq + '9p'],
          '9p' + qqqq : Fqqqq['F' + qqqq + '5p'] / 48
                        - Fqqqq['F' + qqqq + '7p'] / 48
                              }
      # generic case
      if qqqq in ['sbuu', 'sbdd', 'sbuu', 'sbuc', 'sbcu', 'sbcc',
                  'dbuu', 'dbss', 'dbuu', 'dbuc', 'dbcu', 'dbcc',
                  'dsuu', 'dsbb', 'dsuu', 'dsuc', 'dscu', 'dscc',]:
          return {
          '1'+qqqq : -Fqqqq['F' + qqqq + '1']/3 + 4 * Fqqqq['F' + qqqq + '3'] / 3
                     - Fqqqq['F' + qqqq + '2']/(3 * Nc)
                     + 4 * Fqqqq['F' + qqqq + '4'] / (3 * Nc),
          '2'+qqqq : -2 * Fqqqq['F' + qqqq + '2'] / 3
                      + 8 * Fqqqq['F' + qqqq + '4'] / 3,
          '3'+qqqq : Fqqqq['F' + qqqq + '1'] / 12
                     - Fqqqq['F' + qqqq + '3'] / 12
                     + Fqqqq['F' + qqqq + '2'] / (12 * Nc)
                     - Fqqqq['F' + qqqq + '4'] / (12 * Nc),
          '4'+ qqqq : Fqqqq['F' + qqqq + '2'] / 6 - Fqqqq['F' + qqqq + '4'] / 6,
          '5'+ qqqq : -Fqqqq['F' + qqqq + '5'] / 3
                      + 4 * Fqqqq['F' + qqqq + '7'] / 3
                      - Fqqqq['F' + qqqq + '6']/(3 * Nc)
                      + 4 * Fqqqq['F' + qqqq + '8']/(3 * Nc),
          '6'+qqqq : -2 * Fqqqq['F' + qqqq + '6'] / 3
                     + 8 * Fqqqq['F' + qqqq + '8'] / 3,
          '7'+qqqq : Fqqqq['F' + qqqq + '5'] / 3 - Fqqqq['F' + qqqq + '7'] / 3
                     + Fqqqq['F' + qqqq + '9'] + Fqqqq['F' + qqqq + '10'] / Nc
                     + Fqqqq['F' + qqqq + '6']/(3 * Nc)
                     - Fqqqq['F' + qqqq + '8']/(3 * Nc),
          '8'+qqqq : 2*Fqqqq['F' + qqqq + '10'] + 2 * Fqqqq['F' + qqqq + '6'] / 3
                     -2 * Fqqqq['F' + qqqq + '8'] / 3,
          '9'+qqqq : Fqqqq['F' + qqqq + '5'] / 48 - Fqqqq['F' + qqqq + '7'] / 48
                     + Fqqqq['F' + qqqq + '6'] / (48 * Nc)
                     - Fqqqq['F' + qqqq + '8'] / (48 * Nc),
          '10'+qqqq : Fqqqq['F' + qqqq + '6'] / 24 - Fqqqq['F' + qqqq + '8'] / 24,
          '1p'+qqqq : -Fqqqq['F' + qqqq + '1p'] / 3
                      + 4 * Fqqqq['F' + qqqq + '3p'] / 3
                      - Fqqqq['F' + qqqq + '2p'] / (3 * Nc)
                      + 4 * Fqqqq['F' + qqqq + '4p'] / (3 * Nc),
          '2p'+qqqq : -2 * Fqqqq['F' + qqqq + '2p'] / 3
                      + 8 * Fqqqq['F' + qqqq + '4p'] / 3,
          '3p'+qqqq : Fqqqq['F' + qqqq + '1p'] / 12
                      - Fqqqq['F' + qqqq + '3p'] / 12
                      + Fqqqq['F' + qqqq + '2p'] / (12 * Nc)
                      - Fqqqq['F' + qqqq + '4p'] / (12 * Nc),
          '4p'+qqqq : Fqqqq['F' + qqqq + '2p'] / 6 - Fqqqq['F' + qqqq + '4p'] / 6,
          '5p'+qqqq : -Fqqqq['F' + qqqq + '5p'] / 3
                      + 4 * Fqqqq['F' + qqqq + '7p'] / 3
                      - Fqqqq['F' + qqqq + '6p'] / (3 * Nc)
                      + 4 * Fqqqq['F' + qqqq + '8p'] / (3 * Nc),
          '6p'+qqqq : -2 * Fqqqq['F' + qqqq + '6p'] / 3
                      + 8 * Fqqqq['F' + qqqq + '8p'] / 3,
          '7p'+qqqq : Fqqqq['F' + qqqq + '5p'] / 3 - Fqqqq['F' + qqqq + '7p'] / 3
                      + Fqqqq['F' + qqqq + '9p'] + Fqqqq['F' + qqqq + '10p'] / Nc
                      + Fqqqq['F' + qqqq + '6p']/(3 * Nc)
                      - Fqqqq['F' + qqqq + '8p']/(3 * Nc),
          '8p'+qqqq : 2 * Fqqqq['F' + qqqq + '10p']
                      + 2 * Fqqqq['F' + qqqq + '6p'] / 3
                      - 2 * Fqqqq['F' + qqqq + '8p'] / 3,
          '9p'+qqqq : Fqqqq['F' + qqqq + '5p'] / 48
                      - Fqqqq['F' + qqqq + '7p'] / 48
                      + Fqqqq['F' + qqqq + '6p'] / (48 * Nc)
                      - Fqqqq['F' + qqqq + '8p'] / (48 * Nc),
          '10p'+qqqq : Fqqqq['F' + qqqq + '6p'] / 24
                       - Fqqqq['F' + qqqq + '8p'] / 24
                      }
      raise ValueError("Case not implemented: {}".format(qqqq))