Main Content

Classify ECG Signals Using Long Short-Term Memory Networks with GPU Acceleration

This example shows how to classify heartbeat electrocardiogram (ECG) data from the PhysioNet 2017 Challenge using deep learning and signal processing. In particular, the example uses Long Short-Term Memory networks and time-frequency analysis with GPU acceleration. You must have Parallel Computing Toolbox™ and a supported GPU. For details, see GPU Computing Requirements (Parallel Computing Toolbox).

This example reproduces the exclusively CPU version of the time-frequency feature computations found in Classify ECG Signals Using Long Short-Term Memory Networks.

Introduction

ECGs record the electrical activity of a person's heart over a period of time. Physicians use ECGs to detect visually if a patient's heartbeat is normal or irregular.

Atrial fibrillation (AFib) is a type of irregular heartbeat that occurs when the heart's upper chambers, the atria, beat out of coordination with the lower chambers, the ventricles.

This example uses ECG data from the PhysioNet 2017 Challenge [1], [2], [3], which is available at https://physionet.org/challenge/2017/. The data consists of a set of ECG signals sampled at 300 Hz and divided by a group of experts into four different classes: Normal (N), AFib (A), Other Rhythm (O), and Noisy Recording (~). This example shows how to automate the classification process using deep learning. The procedure explores a binary classifier that can differentiate Normal ECG signals from signals showing signs of AFib.

This example uses long short-term memory (LSTM) networks, a type of recurrent neural network (RNN) well-suited to study sequence and time-series data. An LSTM network can learn long-term dependencies between time steps of a sequence. The LSTM layer (lstmLayer (Deep Learning Toolbox)) can look at the time sequence in the forward direction, while the bidirectional LSTM layer (bilstmLayer (Deep Learning Toolbox)) can look at the time sequence in both forward and backward directions. This example uses a bidirectional LSTM layer.

To accelerate feature extraction, training, and inference, this example uses a GPU and Parallel Computing Toolbox.

Load and Examine Data

Run the ReadPhysionetData script to download the data from the PhysioNet website and generate a MAT-file (PhysionetData.mat) that contains the ECG signals in the appropriate format. Downloading the data might take a few minutes. Use a conditional statement that runs the script only if PhysionetData.mat does not already exist in the current folder.

if ~isfile('PhysionetData.mat')
    ReadPhysionetData
end
load PhysionetData

The loading operation adds two variables to the workspace: Signals and Labels. Signals is a cell array that holds the ECG signals. Labels is a categorical array that holds the corresponding ground-truth labels of the signals.

Signals(1:5)
ans=5×1 cell array
    {[-127 -162 -197 -229 -245 -254 -261 -265 -268 -268 -267 -265 -263 -260 -256 -253 -249 -247 -245 -243 -241 -238 -236 -234 -232 -231 -230 -229 -229 -229 -229 -230 -230 -230 -229 -229 -227 -225 -221 -218 -215 -213 -213 -213 -212 -211 -210 -209 -206 -203 -201 -198 -198 -200 -204 -210 -216 -224 -233 -243 -253 -262 -270 -275 -281 -286 -291 -292 -289 -282 -273 -264 -259 -255 -250 -246 -241 -237 -233 -229 -226 -222 -219 -216 -213 -209 -204 -195 -187 -179 -172 -169 -166 -164 -161 -159 -157 -156 -154 -153 -153 -154 -155 -157 -159 -160 -162 -164 -166 -167 -169 -170 -171 -174 -177 -177 -171 -158 -121 -66 11 109 219 331 434 519 575 593 578 533 440 329 213 99 -3 -88 -153 -189 -210 -222 -230 -237 -243 -248 -253 -256 -260 -263 -266 -267 -266 -264 -259 -254 -249 -244 -238 -231 -224 -216 -207 -199 -191 -183 -176 -170 -164 -159 -155 -150 -143 -137 -129 -122 -114 -104 -92 -77 -64 -52 -39 -27 -14 -1 9 18 26 34 42 49 53 56 58 61 64 67 70 72 73 73 73 72 71 69 66 62 58 53 49 45 39 30 21 14 7 0 -7 -13 -14 -10 -4 0 2 5 7 10 14 18 22 25 28 30 31 32 33 35 37 39 41 42 43 45 47 49 52 54 56 59 61 65 68 73 78 87 96 103 106 107 109 110 111 112 113 113 112 111 110 110 109 110 110 110 110 111 112 114 115 117 118 119 121 122 124 126 129 132 136 140 144 148 155 163 167 169 170 171 172 174 176 178 180 182 185 188 192 195 198 201 204 208 212 214 212 208 203 198 194 190 186 182 177 174 171 170 170 171 172 175 179 183 189 195 208 239 302 377 461 547 634 722 803 849 865 845 786 694 593 495 401 310 225 151 113 103 95 91 88 87 87 88 91 94 98 103 108 111 114 117 119 122 125 128 132 135 137 139 141 143 145 147 150 154 157 161 166 171 176 180 182 184 184 183 181 179 176 172 167 161 152 133 118 109 104 99 96 92 88 83 79 75 71 66 61 53 45 37 30 22 5 -22 -51 -77 -100 -125 -150 -178 -200 -214 -228 -242 -250 -254 -257 -259 -261 -264 -267 -270 -272 -274 -276 -278 -280 -283 -286 -292 -308 -323 -335 -344 -352 -364 -376 -388 -400 -412 -421 -430 -448 -475 -502 -526 -547 -570 -592 -618 -648 -680 -709 -729 -738 -745 -751 -754 -748 -736 -716 -689 -670 -658 -645 -632 -616 -597 -582 -568 -554 -535 -515 -496 -481 -472 -467 -464 -460 -457 -452 -447 -442 -435 -426 -412 -389 -376 -360 -337 -314 -289 -274 -267 -261 -256 -250 -245 -239 -233 -227 -221 -212 -202 -190 -172 -148 -130 -116 -104 -92 -78 -68 -60 -54 -49 -47 -45 -43 -41 -40 -38 -35 -33 -40 -52 -59 -66 -72 -76 -78 -77 -74 -67 -55 -18 33 102 193 310 441 567 669 718 735 711 638 511 355 196 56 -43 -96 -122 -144 -173 -195 -207 -215 -218 -215 -209 -202 -194 -186 -178 -168 -159 -152 -146 -141 -136 -133 -130 -126 -123 -119 -115 -111 -107 -103 -98 -92 -86 -80 -75 -69 -62 -53 -41 -26 -7 10 28 41 49 58 67 78 90 101 110 119 130 140 148 154 160 166 171 177 181 187 193 203 217 226 232 236 239 242 244 244 241 233 224 211 192 176 162 151 139 126 119 114 110 107 105 103 102 101 101 101 102 104 105 106 108 110 111 112 112 113 113 115 117 117 115 109 104 101 99 97 94 92 91 90 89 88 88 88 90 96 99 101 103 104 105 107 109 110 111 111 111 111 111 111 110 109 106 102 97 92 87 82 79 76 74 73 73 76 79 84 89 94 100 112 126 142 153 162 169 174 175 173 170 165 159 151 141 130 113 98 88 81 77 73 71 69 67 67 69 71 73 75 77 79 83 87 93 99 104 107 108 108 107 106 104 99 93 85 77 69 61 54 48 43 40 37 34 33 32 34 36 39 40 41 42 45 50 61 83 116 166 238 334 452 584 716 834 906 930 903 819 659 466 274 109 -8 -56 -74 -75 -69 -63 -58 -61 -78 -89 -98 -105 -103 -93 -81 -75 -70 -66 -61 -56 -52 -50 -51 -55 -59 -62 -61 -59 -56 -51 -47 -44 -44 -44 -44 -42 -38 -33 -28 -24 -22 -20 -17 -12 -5 2 14 27 38 50 62 72 82 91 97 98 97 97 97 97 99 99 98 96 93 90 85 78 70 61 51 42 36 31 27 22 17 11 3 -4 -11 -16 -20 -25 -30 -35 -39 -38 -34 -28 -20 -14 -8 -3 0 2 5 9 12 13 13 11 8 6 3 0 -1 -3 -5 -6 -6 -6 -5 -3 -2 -1 -1 0 2 5 7 -1 0 0 1 1 1 1 1 2 2 3 3 3 3 3 4 4 3 2 1 0 0 1 1 1 0 0 0 1 1 1 0 0 -1 -2 -3 -4 -6 -8 -9 -9 -9 -10 -9 -9 -7 -5 -3 -1 0 1 2 3 3 4 4 5 6 7 10 12 15 18 22 25 29 31 33 35 36 38 40 43 46 49 53 58 63 67 69 68 64 58 52 46 42 37 31 25 20 15 11 8 4 1 -3 -10 -20 -26 -30 -33 -37 -39 -35 -23 7 49 107 182 272 378 497 623 744 843 881 872 793 644 457 263 97 -18 -73 -90 -99 -104 -108 -112 -115 -118 -120 -122 -124 -125 -126 -127 -127 -129 -130 -130 -131 -134 -136 -135 -126 -115 -108 -102 -96 -92 -88 -85 -83 -81 -79 -78 -76 -75 -73 -72 -70 -68 -65 -62 -57 -52 -44 -32 -20 -6 6 20 31 42 53 64 71 75 78 80 82 84 86 86 85 82 77 71 66 60 53 45 35 25 15 7 -1 -8 -14 -17 -19 -20 -21 -22 -23 -24 -25 -27 -28 -29 -30 -32 -36 -37 -36 -34 -33 -31 -31 -31 -32 -35 -37 -40 -42 -47 -50 -49 -44 -40 -36 -31 -21 -11 -4 0 6 11 15 16 15 11 6 2 -1 -4 -8 -12 -16 -19 -22 -23 -23 -23 -22 -21 -18 -16 -13 -11 -10 -9 -8 -6 -4 -1 0 3 6 8 9 10 9 9 8 7 6 4 2 0 0 -1 -1 -1 -4 -7 -10 -10 -6 0 6 11 15 20 25 29 32 35 38 40 43 46 49 52 54 56 58 60 62 64 66 68 70 71 70 67 62 57 52 49 45 41 37 33 30 28 26 25 25 25 26 28 30 34 38 43 62 106 169 253 359 479 595 694 764 790 787 742 635 474 288 115 -4 -42 -52 -59 -63 -68 -72 -76 -80 -83 -86 -89 -92 -95 -97 -99 -102 -103 -104 -103 -102 -100 -97 -94 -90 -86 -81 -71 -64 -59 -56 -55 -55 -54 -53 -52 -50 -48 -47 -46 -45 -43 -41 -38 -34 -25 -7 1 7 14 21 29 42 60 69 75 79 81 82 80 76 71 67 64 60 57 54 51 49 46 44 41 38 35 32 28 22 15 10 5 1 -2 -6 -9 -11 -12 -13 -13 -13 -14 -15 -16 -17 -18 -19 -20 -23 -23 -19 -17 -16 -16 -15 -15 -15 -15 -15 -14 -13 -13 -12 -12 -11 -10 -9 -8 -6 -6 -5 -4 -2 2 6 8 6 1 -3 -6 -8 -11 -13 -15 -17 -17 -16 -14 -12 -10 -7 -2 0 0 -3 -6 -9 -8 -3 -1 0 1 2 2 3 3 4 4 4 4 4 3 3 3 3 2 1 0 0 0 0 -1 -1 1 3 4 6 7 10 13 17 21 26 30 34 36 38 40 42 44 47 49 51 53 56 62 74 80 84 86 88 87 86 82 77 59 34 20 12 7 2 -1 -5 -10 -16 -16 -9 -3 0 2 6 9 12 17 36 66 115 188 290 414 549 685 807 897 933 901 798 636 441 247 88 -21 -69 -87 -95 -103 -117 -131 -139 -130 -115 -103 -96 -91 -97 -103 -107 -110 -112 -110 -107 -103 -99 -95 -92 -92 -93 -96 -99 -102 -91 -81 -75 -71 -68 -67 -66 -65 -64 -63 -61 -60 -57 -53 -47 -35 -18 -3 10 18 22 26 33 40 47 52 57 61 64 67 72 78 79 80 81 81 82 79 74 68 61 52 42 33 23 15 9 5 1 -1 -6 -11 -16 -20 -22 -24 -25 -26 -27 -27 -28 -28 -29 -30 -31 -31 -31 -30 -29 -28 -27 -27 -25 -25 -25 -26 -28 -30 -33 -35 -31 -25 -22 -20 -19 -17 -15 -13 -10 -8 -6 -4 -3 -1 0 1 3 5 8 10 12 13 12 10 8 6 4 2 0 -1 -3 -5 -7 -7 -8 -7 -7 -6 -4 -3 -1 0 1 3 5 8 11 14 18 22 26 27 26 23 19 13 5 0 -4 -8 -10 -5 3 7 10 12 14 16 18 21 23 25 27 28 30 32 33 35 36 39 43 47 50 53 56 58 61 64 68 70 72 74 77 81 86 86 76 61 43 34 30 27 24 21 18 15 11 5 -1 -7 -12 -16 -20 -23 -21 -16 -1 19 46 80 129 199 296 415 549 683 803 889 925 899 803 645 453 262 103 -4 -62 -86 -102 -119 -135 -145 -151 -151 -143 -131 -118 -111 -107 -104 -102 -101 -100 -99 -97 -96 -96 -96 -96 -97 -98 -99 -100 -101 -102 -103 -104 -102 -99 -95 -89 -80 -69 -54 -40 -34 -30 -28 -24 -20 -16 -11 -6 0 3 8 26 50 63 71 76 81 84 87 91 96 95 87 82 79 75 71 67 63 57 46 29 16 7 -2 -11 -20 -27 -29 -31 -32 -33 -33 -34 -34 -34 -34 -34 -35 -35 -35 -35 -34 -34 -35 -36 -37 -37 -37 -37 -38 -39 -41 -42 -44 -45 -47 -50 -52 -55 -56 -55 -52 -49 -46 -43 -40 -36 -31 -26 -20 -15 -11 -8 -6 -3 0 0 1 0 0 -1 -3 -5 -8 -10 -12 -13 -15 -16 -17 -18 -18 -18 -17 -16 -15 -14 -12 -11 -9 -8 -6 -5 -3 0 2 5 7 7 7 6 6 5 4 4 2 1 0 -1 -1 -1 0 0 0 0 1 3 5 8 10 18 30 37 43 43 38 34 31 29 30 34 40 46 56 68 84 102 111 117 121 121 116 108 95 78 66 59 52 44 31 18 14 11 9 8 8 10 15 20 27 38 47 56 65 77 106 158 236 339 462 596 724 826 874 874 825 715 567 394 216 62 -41 -76 -75 -54 -42 -51 -76 -114 -137 -144 -135 -121 -102 -86 -78 -72 -67 -63 -61 -60 -59 -58 -57 -56 -56 -55 -55 -55 -55 -54 -53 -52 -52 -52 -51 -51 -50 -50 -48 -47 -45 -41 -31 -21 -11 -1 5 11 16 23 33 39 43 47 51 55 59 62 66 69 73 77 80 81 80 79 76 73 62 35 9 1 -4 -11 -16 -24 -34 -43 -48 -51 -53 -55 -56 -58 -60 -63 -66 -68 -71 -75 -80 -89 -104 -112 -116 -119 -122 -125 -126 -126 -123 -120 -115 -110 -102 -101 -106 -109 -111 -113 -115 -116 -116 -116 -116 -116 -116 -115 -113 -110 -124 -148 -175 -188 -195 -200 -203 -206 -209 -212 -216 -218 -221 -224 -227 -231 -235 -239 -242 -245 -248 -252 -258 -265 -273 -281 -289 -296 -303 -309 -314 -318 -321 -324 -326 -328 -328 -328 -325 -321 -317 -312 -306 -298 -289 -282 -275 -261 -238 -217 -202 -188 -170 -148 -127 -105 -83 -63 -49 -39 -22 1 19 26 31 30 20 13 7 2 0 2 8 18 49 87 125 142 152 159 158 145 127 103 90 84 79 74 70 65 57 28 -7 -31 -59 -78 -90 -89 -63 -8 65 149 232 306 372 431 464 463 422 329 207 75 -46 -149 -233 -300 -345 -365 -374 -379 -382 -386 -391 -397 -403 -413 -426 -427 -415 -404 -393 -383 -374 -369 -366 -364 -361 -357 -353 -350 -346 -340 -329 -306 -290 -281 -272 -263 -236 -202 -166 -142 -116 -88 -39 22 84 134 172 208 230 267 301 322 344 365 396 436 481 520 556 581 606 621 623 625 626 627 622 613 602 589 576 566 559 552 543 534 528 523 519 516 512 508 504 499 495 489 483 477 469 463 457 451 444 434 418 403 389 374 358 341 325 319 316 314 313 311 309 305 301 296 290 280 262 245 228 211 195 185 178 171 164 156 148 141 132 123 113 104 97 89 82 73 63 49 35 25 17 9 3 0 -3 -5 -7 -8 -10 -12 -14 -16 -18 -19 -21 -23 -25 -27 -30 -32 -34 -36 -38 -39 -41 -41 -42 -44 -45 -46 -47 -48 -49 -51 -53 -55 -56 -57 -58 -59 -61 -63 -64 -66 -68 -71 -75 -80 -83 -84 -82 -79 -75 -70 -66 -61 -57 -51 -46 -40 -34 -27 -20 -12 -1 7 7 1 -7 -19 -35 -47 -64 -85 -96 -101 -107 -110 -113 -115 -116 -116 -116 -115 -113 -110 -106 -99 -91 -61 -7 62 144 237 341 450 555 640 679 693 671 604 481 320 147 -12 -132 -205 -231 -240 -249 -248 -234 -210 -184 -173 -168 -164 -161 -159 -156 -153 -151 -149 -147 -145 -144 -143 -144 -144 -144 -144 -142 -140 -138 -136 -134 -133 -131 -129 -127 -124 -121 -118 -115 -111 -107 -101 -95 -88 -82 -77 -73 -68 -61 -47 -19 0 9 18 28 38 48 54 61 67 73 77 78 77 73 67 61 55 49 42 33 26 20 14 10 5 1 -2 -6 -10 -14 -17 -20 -22 -26 -31 -37 -42 -44 -44 -42 -39 -35 -31 -24 -18 -16 -18 -22 -23 -25 -26 -27 -29 -30 -33 -34 -35 -34 -33 -31 -29 -27 -26 -25 -24 -24 -24 -25 -26 -26 -27 -27 -26 -25 -24 -22 -21 -20 -21 -22 -24 -26 -29 -30 -30 -29 -29 -29 -28 -27 -25 -23 -22 -21 -21 -21 -22 -22 -22 -22 -22 -21 -19 -18 -16 -15 -15 -15 -16 -17 -18 -20 -22 -25 -28 -30 -32 -33 -35 -37 -39 -41 -43 -44 … ]}
    {[128 157 189 226 250 257 262 265 268 269 268 266 263 260 258 257 255 252 249 246 244 241 238 235 231 227 223 219 217 213 209 205 200 196 192 190 188 188 189 191 194 198 202 206 209 212 216 219 224 229 234 237 236 233 228 222 217 213 209 206 203 200 197 195 193 191 190 189 188 188 188 188 190 192 196 199 202 204 207 209 211 212 213 214 214 216 218 220 223 225 228 230 232 234 234 234 235 236 237 239 241 242 244 246 249 252 254 255 254 251 247 241 234 226 215 198 185 175 168 164 160 156 153 149 145 140 134 128 120 109 91 78 67 62 59 55 51 48 45 43 40 38 36 35 35 36 36 38 39 41 43 45 48 53 58 85 128 190 273 371 469 553 607 626 626 606 553 465 361 254 159 83 21 -12 -25 -29 -32 -34 -36 -38 -39 -40 -41 -42 -43 -42 -41 -40 -40 -40 -40 -41 -41 -41 -42 -43 -44 -44 -43 -41 -40 -39 -37 -36 -35 -34 -34 -33 -32 -31 -28 -25 -22 -18 -15 -11 -7 -4 -2 0 0 1 2 4 4 5 6 7 8 8 8 8 7 7 6 5 4 3 1 0 -2 -5 -7 -9 -12 -14 -15 -17 -20 -23 -27 -32 -38 -45 -51 -56 -61 -65 -70 -75 -81 -89 -98 -107 -114 -122 -129 -136 -142 -146 -148 -150 -151 -152 -153 -153 -153 -153 -154 -154 -153 -152 -149 -147 -144 -143 -143 -142 -140 -139 -138 -137 -136 -135 -134 -133 -132 -130 -129 -127 -124 -122 -120 -117 -115 -112 -108 -105 -102 -100 -98 -96 -95 -93 -91 -89 -88 -87 -87 -87 -87 -86 -86 -86 -86 -86 -86 -85 -82 -80 -78 -76 -76 -76 -76 -77 -76 -76 -74 -73 -71 -69 -67 -65 -63 -62 -62 -64 -66 -70 -75 -78 -75 -70 -68 -67 -66 -65 -64 -62 -60 -59 -58 -57 -57 -56 -56 -55 -54 -53 -52 -52 -51 -51 -51 -50 -50 -50 -50 -50 -50 -49 -48 -48 -47 -45 -44 -42 -41 -39 -38 -36 -35 -34 -32 -30 -28 -26 -23 -20 -17 -15 -13 -12 -11 -10 -8 -6 -4 -2 0 4 10 17 24 30 36 40 45 49 53 56 58 57 54 48 41 33 26 16 7 0 -5 -10 -13 -16 -19 -22 -24 -26 -28 -30 -31 -32 -32 -31 -30 -29 -29 -29 -28 -27 -27 -25 -23 -21 -18 -15 -11 -6 5 32 73 131 208 296 388 475 546 576 585 563 502 417 317 216 124 47 -13 -41 -49 -54 -56 -57 -56 -55 -53 -51 -50 -49 -48 -46 -44 -43 -42 -42 -43 -44 -45 -46 -48 -51 -53 -55 -56 -58 -59 -60 -59 -51 -41 -30 -23 -17 -12 -8 -4 0 3 6 9 12 15 17 19 21 23 25 29 34 39 45 49 53 58 62 67 71 75 79 83 88 93 98 102 107 112 116 117 114 107 97 87 76 60 46 37 30 25 20 16 12 6 0 -6 -14 -26 -44 -60 -76 -91 -109 -116 -120 -124 -128 -131 -134 -135 -137 -138 -139 -140 -140 -140 -139 -137 -136 -135 -134 -133 -131 -128 -125 -122 -119 -116 -113 -109 -106 -103 -101 -99 -96 -93 -90 -88 -86 -84 -83 -82 -81 -82 -83 -85 -87 -88 -88 -89 -91 -92 -93 -94 -94 -95 -97 -98 -96 -90 -83 -78 -74 -70 -67 -64 -62 -61 -61 -61 -63 -65 -68 -72 -74 -77 -79 -80 -82 -83 -85 -87 -89 -90 -90 -90 -90 -90 -90 -90 -90 -91 -91 -91 -90 -89 -88 -86 -83 -80 -76 -73 -69 -66 -64 -64 -64 -63 -62 -61 -60 -58 -56 -54 -52 -50 -48 -47 -46 -46 -46 -46 -46 -45 -44 -43 -40 -37 -35 -33 -31 -30 -29 -28 -27 -25 -24 -23 -22 -20 -18 -17 -15 -13 -10 -7 -3 1 10 30 47 57 66 72 76 76 71 63 54 44 29 17 6 1 -1 -4 -7 -10 -13 -16 -18 -20 -20 -21 -20 -20 -19 -19 -19 -18 -17 -17 -16 -14 -12 -9 -7 -4 -1 2 9 27 40 70 117 183 264 359 469 583 685 750 754 709 580 418 259 129 35 -1 -15 -16 -5 1 10 16 17 14 10 8 7 6 5 3 0 -2 -4 -4 -2 0 3 7 11 16 20 24 27 28 30 31 33 35 37 39 42 45 49 52 54 56 57 60 63 66 69 73 76 81 86 92 98 102 105 108 111 114 117 121 124 128 133 137 141 145 148 151 154 157 161 164 166 166 163 156 149 142 136 130 125 119 114 109 105 100 96 92 88 83 76 65 54 43 34 26 20 14 8 1 -4 -8 -11 -13 -16 -18 -20 -22 -23 -24 -26 -29 -31 -34 -36 -38 -41 -44 -47 -49 -52 -54 -57 -60 -64 -67 -69 -70 -69 -68 -65 -60 -55 -50 -45 -40 -38 -35 -33 -30 -28 -26 -24 -22 -20 -17 -15 -13 -11 -9 -8 -6 -4 -3 -2 0 0 2 4 5 7 9 10 13 15 18 19 20 22 23 24 25 26 26 26 27 28 29 31 31 33 34 35 36 38 39 40 41 44 47 51 54 55 53 50 44 38 31 23 11 -1 -10 -18 -30 -44 -62 -81 -99 -116 -132 -148 -165 -175 -181 -186 -190 -193 -196 -199 -203 -207 -210 -213 -216 -218 -222 -226 -230 -233 -234 -232 -228 -222 -216 -210 -204 -197 -191 -184 -178 -173 -168 -162 -156 -149 -143 -137 -131 -125 -119 -115 -111 -108 -105 -103 -100 -97 -94 -92 -91 -89 -87 -85 -82 -79 -77 -75 -72 -67 -61 -54 -47 -41 -34 -27 -17 -8 0 7 15 24 29 26 22 17 13 9 10 19 33 55 90 149 224 317 424 542 660 757 793 786 712 568 392 222 88 18 -2 -13 -21 -28 -33 -37 -40 -44 -48 -51 -52 -51 -45 -37 -30 -25 -22 -20 -17 -15 -12 -10 -8 -5 -2 1 5 9 13 16 19 22 24 27 29 31 34 36 39 42 45 48 50 53 56 58 59 61 62 63 64 65 66 68 70 73 75 77 80 82 86 91 96 100 105 108 110 112 115 117 118 120 121 123 124 125 125 122 116 107 97 85 65 49 44 41 38 36 35 34 33 31 30 30 30 30 30 29 29 29 30 30 31 31 30 30 30 31 32 33 33 33 33 33 33 32 32 32 32 32 32 33 34 36 37 39 40 40 40 40 41 42 43 45 46 48 52 56 59 62 64 65 65 66 66 66 66 66 67 68 69 70 71 71 71 70 69 68 67 65 64 63 62 61 61 60 59 58 57 56 55 53 52 51 50 50 50 51 51 50 50 50 50 50 50 50 51 52 53 54 56 58 59 61 63 64 66 67 68 69 70 71 72 73 72 72 71 69 67 65 63 60 57 55 54 52 51 49 46 42 39 35 31 27 23 19 16 14 13 12 10 9 7 5 3 0 -2 -5 -9 -11 -13 -14 -15 -15 -14 -13 -12 -10 -7 -6 -4 -3 -2 -1 0 3 5 8 15 21 22 17 11 7 5 2 0 -2 -4 -7 -10 -13 -16 -20 -25 -33 -40 -41 -38 -33 -30 -27 -25 -23 -22 -21 -19 -18 -16 -14 -12 -11 -11 -11 -10 -9 -8 -5 -2 2 12 37 81 149 237 343 466 599 723 800 805 752 613 441 279 149 53 6 -9 -17 -18 -12 -2 10 27 39 44 47 50 54 57 59 61 63 65 66 66 65 65 64 64 64 65 66 68 69 71 72 74 75 76 77 79 81 84 86 89 92 95 98 100 101 103 104 105 107 108 109 111 113 115 117 119 120 122 123 125 126 126 127 127 129 131 134 138 141 143 144 145 145 145 143 141 138 135 131 128 124 119 111 102 95 88 78 64 49 37 28 20 13 8 3 0 -3 -6 -8 -11 -13 -17 -20 -23 -26 -29 -32 -35 -38 -41 -44 -46 -48 -50 -52 -55 -58 -62 -71 -91 -107 -118 -128 -138 -145 -150 -154 -157 -161 -165 -170 -174 -178 -181 -185 -189 -192 -195 -197 -200 -202 -204 -205 -207 -208 -208 -209 -212 -216 -219 -219 -212 -204 -193 -180 -174 -172 -170 -169 -168 -167 -167 -167 -166 -166 -165 -164 -163 -162 -160 -159 -157 -155 -153 -151 -148 -145 -140 -133 -126 -120 -115 -109 -103 -92 -79 -76 -76 -75 -74 -74 -73 -73 -73 -73 -73 -74 -75 -78 -81 -86 -90 -100 -122 -145 -167 -180 -187 -192 -196 -200 -205 -210 -217 -229 -242 -251 -258 -263 -266 -266 -262 -255 -244 -224 -194 -168 -144 -122 -102 -87 -75 -59 -48 -40 -33 -29 -25 -22 -18 -10 6 27 46 61 72 85 93 98 102 105 106 105 103 100 95 91 85 75 65 54 48 43 38 34 31 28 26 25 25 26 26 26 26 26 26 26 25 24 23 24 26 28 31 33 36 40 44 50 67 101 156 235 338 458 582 693 777 804 794 716 580 420 262 134 52 29 32 56 74 80 82 84 86 88 90 92 95 99 103 106 109 112 114 116 118 119 120 122 124 127 130 133 136 138 139 141 142 144 146 148 152 163 177 183 186 189 191 193 195 197 198 200 202 204 206 209 211 212 213 214 215 216 217 219 222 226 230 233 235 235 235 234 233 232 231 230 229 227 225 223 221 219 215 211 205 196 178 161 142 124 112 100 87 67 54 45 38 31 24 18 11 0 -14 -27 -37 -45 -51 -56 -59 -61 -63 -66 -69 -70 -70 -69 -68 -67 -66 -65 -62 -59 -56 -54 -54 -56 -58 -60 -61 -63 -65 -68 -71 -73 -73 -72 -71 -70 -69 -67 -63 -72 -78 -81 -85 -88 -90 -90 -87 -82 -78 -74 -70 -67 -64 -60 -58 -56 -55 -56 -57 -58 -60 -62 -65 -69 -73 -78 -83 -85 -85 -81 -73 -63 -44 -16 2 16 28 34 40 44 46 47 44 36 26 17 9 0 -10 -17 -19 -19 -18 -17 -16 -16 -15 -14 -12 -8 -2 3 9 15 21 25 25 20 11 3 -2 -7 -11 -15 -19 -22 -26 -30 -33 -36 -38 -40 -42 -44 -46 -47 -48 -49 -51 -52 -53 -55 -55 -56 -56 -56 -55 -54 -53 -51 -48 -45 -42 -39 -35 -31 -26 -21 -17 -13 -9 -5 -1 1 3 5 7 10 12 15 18 19 21 21 21 21 19 17 13 10 7 3 0 -3 -7 -15 -22 -27 -32 -36 -39 -41 -44 -47 -48 -49 -50 -51 -52 -52 -52 -51 -49 -47 -45 -42 -38 -34 -29 -24 -15 4 22 66 132 223 333 451 562 650 679 672 604 478 325 178 50 -45 -81 -94 -93 -80 -75 -73 -70 -68 -66 -65 -65 -65 -64 -64 -63 -63 -63 -63 -62 -61 -59 -57 -55 -53 -52 -51 -50 -49 -48 -46 -45 -43 -40 -37 -32 -28 -24 -20 -16 -12 -9 -7 -5 -3 -2 0 1 4 7 12 16 21 26 32 37 43 48 55 61 67 71 74 76 78 79 81 83 85 86 88 88 89 90 90 90 89 86 82 78 73 68 63 58 53 48 43 37 31 24 17 10 4 -1 -5 -9 -14 -19 -25 -35 -43 -48 -51 -52 -53 -54 -55 -56 -56 -57 -58 -59 -59 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -50 -50 -50 -49 -47 -46 -46 -45 -46 -46 -46 -46 -45 -45 -46 -45 -44 -43 -41 -42 -46 -52 -60 -66 -69 -72 -75 -78 -81 -83 -85 -85 -85 -86 -86 -87 -88 -88 -89 -90 -92 -94 -95 -97 -97 -98 -98 -99 -100 -102 -104 -107 -110 -113 -118 -123 -129 -135 -141 -146 -149 -151 -153 -155 -157 -158 -159 -160 -161 -162 -164 -166 -168 -169 -170 -170 -170 -170 -168 -165 -160 -156 -151 -146 -141 -136 -131 -125 -120 -114 -107 -99 -93 -87 -82 -77 -72 -68 -63 -57 -48 -40 -31 -22 -18 -15 -13 -12 -10 -9 -8 -7 -6 -4 -3 -2 0 1 2 4 5 6 8 10 13 16 19 23 28 36 46 56 65 74 82 87 92 97 102 106 109 111 113 114 114 114 112 110 106 103 99 95 92 89 86 83 79 76 73 70 67 64 61 58 56 55 54 53 52 52 52 53 54 55 56 58 60 62 65 69 73 77 82 112 171 254 361 488 621 737 807 814 779 669 523 369 225 106 21 -1 -6 -11 10 40 63 69 74 78 76 58 45 36 29 25 25 32 41 50 58 67 76 84 92 98 103 107 109 110 111 112 112 112 113 113 113 114 115 116 118 120 121 123 125 127 129 132 135 139 144 149 156 163 170 177 182 187 191 195 198 201 203 204 205 207 209 211 214 215 217 217 218 218 217 216 215 212 209 206 203 199 195 185 162 142 127 107 94 86 79 73 67 63 60 57 53 48 40 30 17 11 7 4 0 -2 -5 -7 -9 -11 -13 -15 -16 -17 -17 -18 -18 -19 -19 -20 -20 -21 -22 -23 -24 -25 -24 -24 -23 -22 -22 -21 -19 -17 -16 -15 -14 -13 -12 -12 -11 -12 -13 -14 -15 -16 -16 -17 -18 -18 -19 -20 -20 -20 -20 -20 -21 -22 -23 -23 -23 -24 -25 -26 -27 -28 -28 -28 -29 -30 -31 -32 -32 -33 -33 -34 -36 -37 -37 -37 -37 -38 -40 -41 -41 -41 -41 -41 -41 -42 -43 -43 -42 -42 -42 -42 -42 -42 -41 -41 -41 -42 -43 -44 -45 -46 -46 -46 -47 -48 -48 -47 -46 -46 -47 -48 -50 -52 -54 -55 -56 -57 -59 -60 -61 -61 -61 -61 -62 -64 -65 -67 -67 -65 -59 -53 -47 -43 -38 -34 -29 -25 -21 -18 -15 -12 -9 -7 -5 -4 -2 0 4 8 11 11 10 6 1 -3 -8 -15 -22 -29 -37 -45 -53 -62 -70 -75 -77 -78 -81 -86 -85 -73 -67 -64 -62 -60 -59 -59 -57 -55 -52 -49 -47 -46 -44 -43 -39 -36 -31 -24 10 68 154 266 393 513 601 625 616 541 416 261 105 -21 -74 -93 -93 -79 -67 -56 -50 -56 -68 -76 -84 -92 -95 -94 -90 -85 -80 -76 -72 -68 -65 -60 -56 -53 -49 -45 -41 -38 -35 -32 -30 -27 -24 … ]}
    {[ 56 73 85 93 100 107 113 117 118 117 115 113 111 109 104 101 107 121 134 147 153 156 159 162 165 167 169 171 173 176 178 181 183 186 190 194 195 191 182 165 114 38 -55 -158 -244 -283 -295 -284 -252 -192 -113 -16 87 180 254 278 285 289 292 294 295 292 286 278 270 264 258 253 247 242 237 232 227 223 220 215 209 195 172 160 154 150 146 142 139 137 134 131 128 125 124 122 120 114 98 77 61 50 41 32 24 16 9 3 0 -5 -9 -14 -19 -23 -28 -35 -44 -52 -60 -68 -76 -83 -92 -100 -105 -105 -101 -94 -84 -68 -42 -24 -9 10 32 52 64 69 73 76 78 80 82 84 87 89 91 93 95 97 99 101 103 105 107 109 110 111 112 111 111 111 110 109 108 107 107 107 107 108 109 109 108 107 106 104 102 100 98 96 94 92 90 89 87 87 87 85 83 80 76 73 69 66 63 59 56 54 52 51 50 48 45 42 37 30 22 15 11 8 7 7 6 4 3 3 3 4 4 5 5 7 10 13 16 17 18 19 20 23 24 26 26 28 30 32 34 36 38 42 47 54 61 67 73 78 81 84 87 89 89 90 90 91 93 94 95 96 97 99 101 103 105 105 106 107 109 112 114 119 127 135 135 125 109 84 46 -14 -91 -180 -267 -329 -351 -352 -338 -300 -243 -174 -96 -14 62 127 148 154 157 160 162 163 160 153 146 141 138 135 132 129 126 124 123 122 120 119 117 116 116 115 114 112 111 110 108 107 105 103 102 100 97 95 92 88 79 68 59 51 42 33 24 14 4 -4 -14 -25 -40 -46 -49 -50 -50 -50 -49 -48 -48 -49 -50 -52 -53 -54 -55 -55 -56 -56 -57 -58 -60 -64 -69 -68 -60 -48 -32 -12 6 15 22 27 31 35 38 42 46 48 51 54 57 60 63 67 71 74 78 81 83 86 87 88 89 89 90 91 94 96 98 99 99 98 97 96 93 89 86 84 88 92 93 95 97 100 102 105 108 110 112 113 113 113 112 112 111 111 110 110 111 113 115 117 119 120 122 123 123 123 122 120 118 116 113 111 109 108 107 106 106 105 103 101 98 95 91 87 83 80 77 76 74 72 70 68 64 55 50 57 69 80 92 101 107 110 111 113 115 116 117 118 120 121 123 125 126 126 125 125 126 127 129 133 139 145 145 138 125 86 34 -36 -123 -217 -307 -380 -404 -393 -359 -254 -129 -10 89 159 192 210 222 227 223 210 192 161 125 104 94 87 89 106 115 119 124 129 133 137 140 142 144 145 146 146 146 146 146 147 149 150 148 141 131 119 100 80 68 60 54 50 46 42 38 35 32 28 23 16 5 -6 -19 -31 -43 -54 -64 -81 -106 -134 -166 -200 -234 -266 -298 -332 -364 -398 -426 -439 -444 -448 -452 -457 -463 -468 -474 -481 -492 -512 -535 -567 -606 -629 -643 -652 -656 -654 -647 -637 -620 -594 -571 -544 -524 -512 -502 -492 -481 -465 -446 -430 -407 -382 -358 -333 -307 -277 -256 -246 -239 -233 -227 -222 -216 -208 -198 -187 -173 -158 -139 -118 -105 -98 -92 -86 -81 -75 -70 -65 -60 -56 -51 -45 -40 -35 -30 -25 -20 -15 -9 -3 4 12 22 33 41 47 53 59 66 73 80 86 93 101 109 117 122 123 124 125 127 130 132 127 119 115 111 107 104 100 97 94 92 91 90 90 90 90 90 90 89 88 86 85 85 90 97 104 109 113 118 122 125 128 131 133 135 136 138 140 141 141 142 142 142 142 143 145 148 150 152 150 145 137 125 102 74 44 -11 -83 -177 -279 -363 -391 -382 -308 -184 -46 74 163 199 214 216 205 194 183 177 177 180 181 181 182 183 185 185 185 183 180 176 172 168 164 163 163 163 163 162 159 156 152 149 146 144 142 141 139 136 129 121 112 102 89 76 63 50 39 31 23 16 8 0 -6 -14 -21 -30 -38 -46 -51 -56 -60 -64 -67 -71 -73 -75 -75 -75 -73 -71 -69 -65 -62 -57 -53 -48 -42 -35 -26 -18 -10 -3 2 7 12 15 18 21 24 27 29 30 30 30 30 30 29 28 27 27 28 29 30 31 31 32 32 32 31 31 31 31 32 33 33 33 33 33 31 29 27 26 23 21 19 18 18 18 19 19 19 20 22 23 25 26 28 30 35 40 46 50 53 56 59 62 65 67 69 70 71 72 72 71 70 68 67 65 63 61 59 56 54 51 48 46 43 41 38 36 35 33 31 28 25 22 19 16 12 9 7 4 2 1 1 1 1 2 3 4 6 8 11 14 17 21 25 30 35 39 43 48 53 59 65 70 74 77 78 79 79 78 76 74 70 66 61 55 43 13 -40 -118 -217 -323 -417 -459 -474 -449 -373 -263 -144 -32 61 92 100 106 109 111 111 108 103 97 92 88 84 79 76 74 72 70 67 65 62 59 57 55 53 51 48 45 42 38 35 31 28 25 21 16 11 7 3 0 -2 -6 -11 -15 -21 -27 -38 -50 -64 -77 -85 -91 -96 -100 -105 -109 -113 -118 -123 -129 -134 -138 -142 -146 -152 -161 -171 -178 -178 -174 -166 -157 -145 -126 -107 -90 -76 -62 -50 -40 -33 -27 -21 -15 -6 1 8 13 18 23 26 30 34 37 39 40 40 39 38 37 35 34 33 31 30 29 28 27 24 21 20 21 23 26 28 32 37 42 45 44 39 34 30 25 20 17 17 19 22 25 26 27 28 30 32 33 35 36 36 36 36 35 34 33 32 31 31 31 32 33 34 34 34 34 33 33 33 33 33 33 33 34 36 37 38 39 40 40 41 42 42 42 41 43 48 47 30 21 15 9 3 0 -3 -4 -6 -8 -9 -10 -10 -10 -10 -10 -11 -12 -10 -2 8 19 32 43 52 56 58 61 64 67 69 71 73 75 75 75 75 74 73 71 69 66 62 58 53 49 23 -17 -76 -151 -236 -325 -411 -463 -481 -454 -372 -232 -83 41 123 150 160 163 154 138 129 122 115 109 104 101 99 98 97 97 98 98 99 99 99 98 97 95 94 90 86 81 76 72 68 65 61 57 54 50 46 42 39 35 31 26 19 5 -9 -23 -34 -45 -56 -65 -74 -84 -97 -111 -121 -129 -137 -144 -149 -154 -159 -162 -165 -168 -172 -175 -177 -177 -175 -170 -164 -156 -149 -139 -123 -110 -99 -93 -88 -85 -82 -78 -74 -70 -66 -63 -60 -58 -55 -52 -48 -45 -42 -40 -39 -37 -34 -31 -28 -26 -26 -27 -30 -33 -35 -36 -37 -39 -41 -42 -43 -45 -46 -49 -51 -53 -53 -53 -53 -54 -55 -56 -57 -59 -60 -62 -63 -64 -64 -62 -58 -53 -47 -39 -24 -9 -4 0 1 3 5 6 7 9 9 9 9 10 10 10 10 11 11 11 11 11 11 11 12 12 13 13 13 13 13 14 18 21 21 16 8 -2 -15 -16 -17 -19 -20 -22 -22 -19 -14 -9 -4 2 6 4 -1 -3 -6 -8 -11 -12 -12 -11 -9 -6 -3 0 4 12 19 25 30 35 42 47 45 41 38 35 32 30 30 33 37 41 46 54 55 45 31 12 -8 -31 -73 -125 -186 -252 -322 -389 -433 -448 -427 -359 -236 -88 46 137 163 159 131 116 111 109 108 106 105 103 101 99 95 88 75 66 62 60 60 66 72 77 82 86 88 87 84 80 75 71 66 61 55 49 42 37 33 30 26 23 20 17 15 13 10 6 0 -11 -22 -34 -45 -55 -64 -71 -81 -94 -101 -105 -109 -113 -116 -119 -120 -121 -121 -120 -119 -118 -115 -111 -106 -100 -87 -64 -46 -32 -18 -6 4 11 16 18 20 21 22 22 22 22 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 25 27 27 28 30 31 34 38 42 44 42 38 34 30 25 20 17 14 12 10 8 6 3 1 0 -1 -3 -7 7 17 22 27 31 33 34 32 29 25 21 17 14 12 9 6 3 0 -1 -4 -6 -8 -11 -13 -15 -17 -18 -20 -22 -23 -25 -27 -28 -30 -31 -32 -34 -36 -37 -38 -40 -41 -45 -54 -64 -76 -85 -89 -92 -95 -93 -80 -61 -39 -19 -2 6 11 15 18 18 15 10 5 1 -3 -8 -11 -12 -10 -6 -2 4 14 19 25 30 20 -11 -52 -100 -156 -220 -287 -348 -380 -390 -378 -340 -282 -209 -128 -43 30 84 112 123 126 123 115 100 87 83 81 79 75 70 63 49 27 11 1 -3 0 9 23 37 43 46 48 49 48 46 42 38 34 30 25 19 12 3 -6 -18 -27 -34 -39 -45 -50 -56 -62 -66 -69 -72 -75 -79 -82 -86 -90 -94 -99 -106 -113 -119 -126 -132 -140 -144 -139 -131 -124 -119 -114 -110 -105 -102 -97 -87 -68 -50 -36 -26 -14 3 17 27 31 30 26 21 15 16 26 34 41 48 52 55 60 65 65 57 52 49 45 42 41 42 44 46 48 49 50 52 54 56 56 54 51 47 43 40 35 30 25 23 22 23 24 25 25 25 25 26 27 27 28 28 29 29 30 30 29 28 27 26 26 26 25 25 27 29 31 32 32 32 28 24 19 16 12 8 4 1 0 -2 -4 -8 -10 -7 0 4 8 12 14 15 14 12 10 9 6 3 4 12 21 26 31 36 40 44 45 46 46 45 44 43 41 38 38 42 46 50 39 23 2 -34 -85 -148 -212 -266 -310 -322 -328 -320 -272 -198 -105 -13 64 123 159 172 172 158 121 86 67 57 51 48 45 42 40 36 31 24 24 29 34 38 42 44 42 36 29 25 20 15 12 10 10 10 11 11 12 14 3 -6 -12 -17 -24 -31 -37 -44 -50 -55 -61 -66 -72 -80 -88 -97 -104 -110 -115 -119 -123 -126 -129 -134 -137 -137 -133 -126 -121 -115 -109 -102 -94 -80 -60 -44 -32 -19 -11 -7 -3 0 2 5 9 12 16 21 31 53 69 78 85 91 96 99 102 105 109 111 111 109 105 100 95 91 87 82 77 72 67 62 56 51 48 45 44 42 40 39 37 35 33 32 30 29 27 26 25 25 25 24 24 24 24 24 25 25 25 25 25 26 26 26 26 25 24 23 23 22 20 19 17 16 15 13 10 6 1 -4 -8 -12 -14 -16 -17 -18 -18 -18 -17 -17 -18 -19 -19 -18 -14 -9 -5 -2 2 6 10 13 14 13 13 13 12 11 9 8 10 17 24 32 37 40 44 47 30 0 -27 -71 -116 -169 -222 -278 -338 -401 -442 -456 -433 -366 -248 -107 15 70 90 90 78 66 53 35 21 10 3 2 2 1 1 0 0 0 0 0 0 0 1 2 3 3 3 3 2 2 1 0 -1 -3 -4 -6 -8 -10 -12 -14 -17 -21 -25 -29 -35 -41 -47 -53 -59 -64 -70 -75 -80 -84 -87 -90 -93 -97 -104 -114 -127 -134 -138 -142 -145 -146 -147 -148 -147 -145 -142 -138 -134 -127 -118 -100 -83 -65 -47 -36 -26 -17 -7 4 13 20 27 33 39 44 47 50 52 54 57 59 60 61 63 65 66 67 67 67 67 67 67 69 69 70 72 77 69 62 56 52 50 51 55 61 70 80 84 87 91 91 83 76 69 64 63 68 75 87 104 111 116 120 123 121 116 111 107 103 100 97 94 90 85 81 77 73 67 58 46 32 24 18 13 9 5 1 -2 -4 -6 -7 -8 -10 -12 -17 -23 -32 -37 -42 -46 -49 -48 -45 -39 -33 -25 -15 -6 0 3 6 9 11 13 15 16 17 17 17 17 16 14 12 10 7 2 -2 -8 -23 -51 -91 -139 -197 -260 -329 -398 -447 -451 -420 -317 -177 -33 79 141 162 151 134 107 73 50 37 29 40 58 75 82 88 90 85 78 75 73 72 71 70 70 69 68 66 65 63 62 61 60 58 57 56 55 54 53 51 48 45 39 34 31 31 32 32 33 34 35 35 29 19 7 -8 -22 -31 -38 -43 -49 -56 -62 -68 -72 -77 -81 -85 -88 -89 -87 -85 -81 -76 -71 -63 -48 -33 -20 -10 -2 0 3 4 6 7 8 9 9 8 6 3 1 -1 -4 -7 -11 -14 -17 -17 -17 -16 -15 -13 -10 -6 -4 -9 -19 -26 -31 -36 -39 -41 -41 -40 -37 -33 -27 -21 -11 -6 -10 -18 -29 -43 -48 -50 -52 -54 -54 -52 -48 -42 -37 -35 -32 -30 -26 -23 -21 -18 -16 -15 -14 -14 -14 -15 -17 -18 -19 -21 -22 -23 -24 -24 -25 -27 -28 -29 -31 -32 -34 -37 -40 -44 -49 -55 -64 -69 -65 -58 -52 -45 -42 -44 -46 -48 -51 -53 -54 -53 -49 -44 -36 -20 -11 -7 -4 -1 0 3 5 7 9 12 15 18 23 31 38 44 53 62 74 85 95 95 83 68 48 17 -20 -70 -130 -198 -273 -346 -401 -408 -385 -294 -163 -30 78 126 140 149 152 152 150 146 138 111 75 62 58 55 53 52 51 52 52 54 56 59 61 63 66 69 72 75 76 76 73 70 66 63 60 57 52 48 42 35 28 21 13 5 0 -4 -8 -12 -16 -21 -27 -32 -39 -53 -73 -82 -86 -90 -93 -96 -98 -99 -100 -101 -101 -101 -101 -100 -99 -97 -95 -94 -91 -89 -85 -75 -64 -53 -41 -30 -22 -18 -14 -11 -9 -5 -2 2 6 9 12 14 17 21 23 25 27 28 28 27 26 25 23 20 18 15 14 13 11 10 9 9 9 9 8 8 7 6 6 6 6 6 6 6 7 8 9 9 9 10 10 10 7 2 15 24 28 33 36 38 39 38 38 38 39 39 39 39 38 38 37 37 37 38 37 37 37 38 38 39 39 39 38 37 36 36 36 35 32 27 24 22 20 19 16 13 11 8 6 4 3 1 0 -1 -2 -4 -6 -10 -14 -17 -17 -14 -10 -4 3 16 27 43 60 68 73 77 80 81 80 77 72 67 62 53 49 52 58 64 70 73 72 66 53 15 -36 -103 -180 -261 -336 -378 -392 -372 -313 -221 -119 -27 42 91 126 137 143 143 136 126 119 114 109 105 101 96 92 88 85 82 79 74 66 61 60 59 59 59 58 57 56 55 54 52 50 46 43 40 37 35 30 25 20 15 10 7 3 0 -3 -7 -12 -16 -21 -26 -33 -44 -54 -62 -76 -95 -104 -108 -113 -117 -119 -120 -117 -113 -108 -103 -98 -92 -84 -75 -65 -56 -48 -39 -32 -27 -25 -23 … ]}
    {[519 619 723 827 914 956 955 934 920 900 889 883 877 873 870 866 863 860 858 856 854 852 851 849 847 845 842 840 837 834 832 830 829 829 829 830 831 833 835 837 839 842 845 849 853 859 872 885 896 906 916 926 935 939 942 944 946 948 949 951 951 950 946 940 932 921 903 888 870 844 816 788 759 729 699 670 643 616 590 564 543 527 508 495 486 480 473 467 461 454 445 432 419 407 395 383 370 356 350 347 345 343 342 341 340 338 337 335 333 331 329 328 326 325 324 322 321 318 315 311 305 299 294 289 284 280 275 271 267 263 259 255 250 244 238 231 222 212 203 195 189 182 176 171 166 161 155 148 140 132 123 112 102 96 92 88 86 85 84 82 81 81 80 80 79 79 78 78 78 78 78 77 76 73 71 68 65 61 57 53 48 43 35 14 3 -2 -6 -10 -13 -17 -20 -23 -26 -28 -30 -32 -33 -34 -34 -35 -35 -36 -38 -40 -43 -46 -48 -49 -50 -51 -51 -52 -53 -54 -57 -63 -61 -47 -8 57 152 269 400 527 634 697 718 704 663 584 480 362 249 148 67 13 -4 -16 -25 -31 -34 -36 -38 -39 -41 -42 -43 -44 -45 -46 -48 -49 -49 -50 -50 -49 -47 -45 -43 -41 -40 -39 -37 -35 -33 -31 -29 -26 -21 -15 -9 -3 1 6 11 17 21 25 29 32 36 41 44 48 51 55 60 68 84 98 111 125 145 157 165 172 178 183 188 192 195 199 204 208 212 213 211 207 201 192 177 149 127 110 91 72 54 36 19 1 -16 -33 -50 -68 -83 -94 -104 -115 -125 -135 -145 -156 -168 -179 -186 -193 -198 -203 -207 -209 -210 -210 -209 -206 -203 -198 -192 -185 -176 -164 -153 -143 -135 -131 -128 -125 -122 -121 -119 -118 -117 -115 -115 -115 -115 -116 -117 -118 -120 -122 -124 -127 -129 -132 -134 -136 -139 -141 -143 -146 -149 -154 -159 -164 -169 -173 -178 -183 -188 -192 -196 -200 -203 -206 -209 -212 -213 -214 -213 -211 -208 -205 -201 -196 -190 -184 -177 -166 -156 -149 -144 -140 -138 -137 -136 -135 -135 -134 -133 -132 -131 -131 -130 -130 -129 -129 -130 -130 -130 -129 -129 -129 -129 -129 -129 -128 -128 -127 -127 -128 -128 -127 -126 -125 -124 -124 -123 -122 -121 -119 -118 -117 -116 -116 -114 -113 -111 -110 -108 -107 -106 -105 -104 -104 -104 -103 -103 -101 -100 -98 -96 -94 -91 -88 -84 -80 -77 -74 -70 -66 -60 -54 -48 -43 -39 -37 -34 -33 -32 -31 -31 -31 -29 -27 -26 -26 -28 -31 -36 -41 -48 -59 -59 -39 13 98 216 364 532 708 867 982 1027 981 844 652 442 260 133 63 31 6 -20 -34 -40 -45 -49 -52 -54 -55 -55 -54 -52 -49 -45 -41 -36 -31 -28 -26 -24 -22 -20 -18 -17 -17 -16 -16 -15 -14 -13 -12 -10 -9 -7 -5 -4 -3 -2 -2 0 0 0 1 2 4 6 8 11 14 17 21 34 45 54 63 72 81 93 108 124 141 158 175 192 206 218 225 228 229 231 233 235 236 232 224 214 203 188 176 165 155 144 133 123 111 97 80 63 45 25 4 -16 -34 -50 -64 -75 -83 -87 -89 -92 -94 -95 -96 -97 -97 -98 -98 -97 -95 -92 -88 -84 -80 -76 -72 -68 -65 -63 -62 -61 -59 -57 -56 -54 -53 -52 -51 -50 -49 -48 -48 -47 -47 -47 -46 -46 -45 -45 -45 -45 -45 -44 -44 -44 -44 -46 -47 -49 -51 -52 -53 -54 -56 -57 -58 -58 -59 -59 -60 -61 -62 -63 -65 -66 -67 -69 -70 -71 -72 -73 -74 -74 -74 -74 -75 -75 -75 -76 -76 -76 -76 -77 -77 -76 -76 -76 -76 -75 -75 -75 -75 -75 -74 -72 -71 -70 -69 -68 -67 -66 -65 -64 -64 -64 -64 -64 -64 -65 -65 -66 -66 -67 -67 -68 -69 -69 -69 -69 -69 -68 -68 -67 -66 -64 -63 -62 -61 -60 -58 -56 -54 -52 -49 -45 -40 -35 -30 -25 -22 -19 -17 -15 -14 -13 -13 -13 -11 -9 -5 -2 0 0 -1 -3 -5 -9 -14 -20 -7 33 99 195 324 482 662 850 1024 1134 1144 1082 898 657 417 232 135 100 84 70 52 27 -4 -19 -24 -29 -34 -38 -40 -42 -44 -46 -47 -47 -48 -47 -45 -43 -40 -37 -34 -31 -27 -23 -19 -15 -11 -8 -4 0 3 7 10 13 16 19 21 23 25 27 28 30 33 36 41 51 62 75 83 88 91 95 99 103 108 113 119 125 132 140 153 165 173 179 184 188 192 195 198 199 199 198 195 190 184 177 166 146 131 117 103 88 76 65 57 49 45 42 40 38 36 33 30 27 24 20 17 13 8 3 -1 -6 -11 -16 -20 -25 -30 -34 -38 -42 -46 -48 -50 -51 -52 -53 -54 -55 -56 -57 -59 -61 -62 -63 -64 -65 -66 -66 -67 -67 -67 -68 -69 -71 -73 -75 -77 -77 -76 -73 -68 -62 -56 -50 -42 -34 -31 -30 -29 -28 -28 -28 -28 -28 -28 -28 -28 -28 -28 -28 -29 -29 -29 -29 -30 -30 -30 -31 -31 -31 -31 -31 -32 -32 -32 -33 -33 -34 -35 -36 -36 -36 -37 -37 -37 -37 -37 -38 -40 -41 -41 -40 -37 -35 -33 -31 -30 -28 -27 -25 -24 -24 -23 -23 -23 -23 -23 -23 -24 -26 -27 -29 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58 -62 -66 -70 -72 -73 -72 -70 -67 -63 -59 -56 -52 -47 -42 -39 -37 -36 -35 -34 -33 -31 -30 -29 -28 -28 -29 -29 -30 -31 -33 -34 -29 -21 -19 -17 -15 -14 -12 -10 -9 -7 -5 -4 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -2 -1 0 0 1 2 3 4 4 5 6 6 6 7 6 6 6 6 8 10 11 13 15 17 18 19 21 24 29 49 103 186 304 455 636 831 1018 1160 1223 1185 1044 822 577 372 238 178 153 136 114 68 20 -16 -36 -43 -46 -48 -50 -51 -53 -54 -55 -57 -58 -59 -60 -60 -60 -59 -59 -60 -60 -60 -60 -61 -61 -61 -60 -59 -58 -57 -55 -54 -53 -51 -48 -46 -43 -36 -15 3 16 32 45 56 64 72 78 83 87 93 100 109 119 131 143 154 164 173 181 187 194 201 209 217 226 232 237 241 244 245 244 242 237 232 221 202 185 167 152 140 131 119 102 86 75 64 58 54 51 48 46 43 40 37 34 29 22 15 8 0 -10 -20 -31 -41 -53 -62 -68 -73 -79 -84 -89 -96 -105 -111 -114 -117 -119 -120 -122 -123 -123 -124 -124 -124 -123 -122 -119 -116 -112 -108 -103 -98 -88 -78 -71 -64 -57 -51 -46 -41 -38 -35 -33 -33 -32 -31 -31 -30 -30 -29 -29 -29 -29 -29 -29 -29 -30 -30 -29 -29 -29 -29 -29 -30 -31 -31 -32 -32 -33 -33 -33 -33 -34 -34 -35 -35 -36 -39 -41 -44 -46 -49 -50 -51 -52 -53 -54 -55 -55 -56 -57 -58 -59 -61 -62 -63 -63 -63 -63 -61 -59 -57 -54 -51 -48 -45 -43 -41 -39 -36 -33 -31 -29 -27 -25 -23 -22 -21 -20 -20 -20 -20 -20 -19 -19 -17 -16 -17 -23 -29 -34 -38 -43 -46 -47 -46 -42 -38 -34 -32 -30 -29 -27 -26 -25 -24 -23 -22 -21 -19 -18 -17 -16 -15 -14 -13 -11 -10 -8 -5 -3 0 2 8 14 19 21 23 25 27 29 30 32 33 32 29 25 22 20 19 17 15 14 12 10 9 8 8 7 7 8 8 9 10 11 12 13 14 15 16 17 17 19 20 21 23 24 28 32 31 27 22 18 13 9 7 6 7 12 18 25 33 44 52 55 57 59 62 64 60 50 39 26 22 17 14 23 52 108 192 310 468 655 853 1039 1178 1238 1195 1050 829 579 356 208 157 141 129 120 91 49 8 -28 -44 -52 -57 -59 -57 -48 -39 -35 -32 -29 -26 -23 -21 -19 -17 -16 -15 -14 -13 -12 -12 -12 -13 -13 -13 -14 -15 -16 -17 -17 -17 -17 -16 -16 -16 -15 -14 -13 -11 -9 -7 -5 -1 6 25 41 54 66 82 102 122 143 165 184 198 216 232 243 253 259 262 265 268 270 270 269 267 265 261 256 249 236 225 211 190 166 142 120 104 88 67 43 22 1 -14 -27 -40 -53 -65 -71 -74 -76 -77 -78 -79 -79 -78 -77 -75 -72 -68 -64 -59 -55 -52 -48 -46 -43 -41 -38 -37 -35 -34 -34 -34 -35 -36 -38 -40 -43 -46 -49 -52 -55 -57 -60 -62 -64 -66 -68 -70 -70 -70 -70 -69 -67 -66 -63 -61 -59 -56 -54 -52 -50 -49 -47 -45 -44 -43 -42 -41 -40 -39 -38 -37 -37 -37 -37 -38 -39 -41 -43 -46 -48 -51 -53 -55 -56 -58 -60 -61 -63 -65 -68 -71 -74 -77 -81 -83 -86 -88 -89 -90 -90 -91 -92 -94 -95 -97 -99 -101 -103 -104 -105 -104 -101 -98 -94 -89 -85 -80 -72 -65 -58 -53 -48 -45 -43 -41 -39 -37 -36 -34 -32 -29 -26 -23 -20 -18 -15 -12 -9 -6 -2 1 5 9 13 16 18 17 14 10 4 -1 -7 -15 -29 -40 -46 -51 -53 -56 -58 -61 -64 -66 -68 -68 -69 -70 -70 -70 -69 -68 -66 -64 -62 -60 -58 -55 -52 -49 -44 -36 -27 -19 -11 -3 5 16 24 32 36 39 41 43 45 47 49 50 52 53 56 59 74 119 195 307 459 643 848 1047 1204 1267 1256 1136 910 641 385 197 123 98 85 77 49 3 -46 -61 -64 -66 -67 -68 -68 -68 -67 -66 -62 -58 -54 -48 -40 -28 -17 -6 -1 0 2 3 5 6 7 8 9 10 12 14 15 16 17 18 19 20 21 23 25 28 34 46 57 67 74 79 84 88 92 96 99 104 111 123 137 151 165 180 194 205 216 226 238 251 266 275 282 288 291 291 288 282 275 266 251 235 219 203 184 158 127 104 85 65 44 24 6 -7 -19 -33 -49 -58 -65 -72 -77 -82 -85 -88 -90 -91 -93 -94 -95 -96 -96 -97 -99 -100 -100 -98 -93 -85 -77 -70 -66 -63 -59 -55 -52 -49 -47 -45 -43 -42 -40 -39 -39 -39 -39 -40 -40 -41 -43 -45 -47 -49 -51 -52 -54 -55 -57 -58 -59 -60 -61 -61 -62 -62 -62 -61 -60 -59 -58 -58 -58 -58 -57 -53 -47 -41 -38 -34 -30 -27 -25 -23 -22 -23 -26 -30 -35 -41 -46 -51 -54 -57 -60 -63 -65 -67 -69 -71 -73 -75 -76 -78 -79 -79 -79 -78 -77 -76 -74 -72 -69 -67 -65 -63 -61 -59 -57 -56 -54 -53 -52 -51 -50 -49 -47 -46 -44 -43 -43 -42 -42 -42 -42 -43 -44 -45 -47 -47 -47 -48 -48 -48 -48 -48 -47 -47 -46 -46 -46 -46 -46 -45 -43 -42 -41 -39 -38 -36 -34 -33 -31 -31 -30 -30 -29 -27 -26 -25 -24 -23 -22 -21 -19 -19 -19 -19 -19 -20 -20 -19 -18 -17 -16 -15 -13 -10 -7 -4 -1 0 2 5 7 9 11 12 14 16 17 19 21 23 24 25 27 27 28 28 28 27 27 26 25 23 22 21 20 19 18 16 15 14 13 12 12 11 10 8 7 6 3 -3 -9 -9 0 15 62 138 248 394 576 782 998 1194 1318 1330 1262 1057 791 524 310 181 137 124 109 94 69 27 -2 -17 -29 -39 -47 -54 -59 -65 -71 -76 -80 -81 -80 -75 -69 -63 -58 -53 -48 -43 -37 -31 -26 -21 -16 -11 -6 -1 2 6 10 15 19 24 29 34 38 43 49 55 62 69 74 80 85 90 94 99 103 107 112 117 122 128 135 144 159 173 189 202 215 225 233 239 243 247 250 253 255 256 254 251 245 237 229 218 201 186 173 158 140 123 106 89 70 50 31 11 -2 -13 -22 -29 -35 -40 -46 -53 -60 -69 -77 -83 -88 -92 -96 -98 -98 -96 -92 -87 -82 -79 -77 -75 -73 -71 -69 -67 -64 -62 -59 -57 -56 -54 -53 -52 -52 -51 -51 -50 -49 -47 -46 -46 -45 -45 -45 -45 -46 -47 -48 -49 -51 -52 -52 -53 -54 -54 -54 -54 -54 -55 -55 -56 -56 -57 -57 -57 -56 -56 -55 -54 -53 -53 -52 -53 -53 -54 -55 -57 -58 -60 -61 -62 -63 -64 -64 -65 -65 -67 -69 -72 -74 -76 -76 -76 -75 -73 -70 -68 -65 -63 -61 -60 -59 -59 -58 -57 -57 -56 -55 -53 -51 -49 -46 -43 -41 -39 -38 -36 -34 -33 -33 -33 -32 -32 -31 -29 -28 -27 -26 -26 -25 -25 -25 -25 -25 -25 -25 -25 -25 -25 -24 -24 -23 -22 -21 -21 -21 -21 -21 -21 -20 -20 -20 -20 -19 -19 -19 -18 -17 -17 -16 -16 -15 -14 -13 -13 -11 -9 -7 -4 -2 0 2 4 5 7 8 9 10 10 10 10 9 9 8 8 8 8 8 8 8 8 7 6 5 4 3 3 3 3 3 3 4 5 6 7 7 7 7 6 6 5 5 4 4 3 3 3 4 4 4 4 4 3 1 0 0 0 -1 -2 -2 -2 -2 -1 -1 0 0 0 1 2 4 6 8 10 13 16 21 27 32 35 37 39 40 41 42 43 43 44 44 44 45 44 44 43 42 40 39 38 36 35 34 34 34 33 33 32 30 29 27 26 24 23 21 20 18 15 7 0 1 7 17 46 113 215 355 529 726 927 1109 1217 1224 1148 940 665 387 174 83 52 64 82 94 75 42 11 1 -2 -5 -7 -8 -9 -11 -13 -14 -15 -16 -16 -15 -15 -14 -14 -14 -13 -12 -12 -11 -11 -10 -9 -8 -6 -5 -4 -3 -2 -1 0 1 2 4 6 8 14 22 29 36 44 53 62 72 80 89 100 115 133 158 184 203 218 238 251 259 266 271 272 272 272 272 272 271 271 271 271 271 267 261 253 244 233 222 213 197 175 153 129 107 91 76 56 31 12 -2 -16 -30 -45 -63 -80 -94 -104 -111 -116 -120 -123 -125 -126 -124 -119 -113 -106 -95 -79 -64 -58 -53 -49 -46 -43 -41 … ]}
    {[  -188 -239 -274 -316 -356 -374 -380 -384 -387 -389 -390 -391 -392 -393 -393 -394 -394 -395 -397 -398 -400 -401 -402 -402 -402 -403 -403 -403 -405 -407 -409 -412 -415 -418 -422 -428 -436 -444 -450 -456 -463 -470 -479 -487 -495 -504 -511 -515 -519 -523 -527 -530 -532 -534 -535 -535 -534 -532 -530 -526 -522 -517 -511 -502 -482 -466 -430 -379 -303 -198 -65 78 207 286 312 300 266 190 94 -19 -145 -267 -364 -408 -423 -403 -387 -377 -370 -363 -356 -350 -346 -342 -338 -334 -331 -328 -325 -322 -318 -315 -310 -305 -299 -292 -280 -269 -261 -254 -249 -245 -242 -239 -236 -233 -229 -225 -221 -217 -211 -202 -189 -176 -164 -151 -134 -116 -101 -90 -79 -69 -59 -49 -39 -30 -22 -15 -10 -7 -3 -1 1 2 2 1 -2 -8 -15 -22 -31 -46 -60 -73 -89 -106 -115 -119 -121 -123 -124 -125 -126 -127 -127 -127 -126 -126 -125 -125 -124 -124 -123 -122 -121 -119 -117 -116 -114 -112 -110 -107 -105 -102 -99 -96 -90 -71 -54 -47 -43 -40 -38 -35 -34 -33 -32 -31 -30 -28 -27 -25 -24 -22 -20 -18 -16 -13 -10 -7 -3 1 13 22 25 27 29 31 33 35 37 39 40 40 40 40 39 37 36 34 32 31 31 31 32 32 32 32 32 31 30 29 27 26 26 26 26 27 27 28 29 30 32 33 33 33 33 35 37 40 42 45 48 53 59 65 71 76 80 82 84 85 86 86 88 90 94 96 98 99 99 100 100 100 100 99 99 99 100 103 105 107 109 110 111 110 108 105 102 100 98 96 95 93 91 90 87 84 81 80 81 84 91 99 107 118 129 138 147 152 156 159 162 163 164 165 165 165 164 163 162 161 159 158 155 152 150 147 145 143 140 136 132 126 120 108 88 74 56 29 10 -1 -9 -14 -16 -18 -19 -21 -24 -22 -6 36 93 178 297 443 589 709 766 784 765 709 621 505 365 220 88 -7 -38 -46 -52 -56 -58 -59 -60 -60 -59 -58 -55 -52 -47 -44 -41 -38 -36 -34 -32 -30 -29 -27 -26 -25 -24 -23 -21 -20 -18 -15 -13 -11 -8 -6 -4 -1 1 4 8 12 16 20 23 28 33 39 46 55 66 76 86 91 96 100 103 107 110 113 114 114 114 113 112 109 106 102 97 92 87 81 70 58 48 38 30 22 15 7 -1 -10 -18 -24 -29 -33 -37 -41 -43 -46 -48 -51 -54 -56 -58 -59 -60 -61 -62 -63 -64 -66 -67 -68 -69 -70 -70 -70 -68 -66 -63 -60 -56 -52 -48 -45 -42 -39 -35 -31 -27 -23 -19 -16 -13 -10 -9 -8 -7 -8 -7 -7 -7 -6 -5 -3 -2 -1 0 0 -1 -3 -5 -7 -9 -11 -12 -14 -15 -17 -18 -19 -20 -20 -20 -20 -19 -16 -14 -12 -9 -6 -2 1 5 13 32 46 83 128 203 318 478 677 889 1069 1160 1118 940 667 374 134 -8 -35 -45 -39 -31 -24 -25 -38 -45 -49 -52 -56 -58 -60 -62 -64 -64 -62 -60 -56 -51 -46 -41 -37 -34 -32 -31 -29 -26 -24 -22 -19 -17 -14 -11 -8 -5 -3 0 3 8 13 18 24 30 37 44 51 58 64 70 77 83 91 101 114 125 133 139 146 151 153 149 140 128 113 91 75 62 50 37 22 3 -15 -28 -40 -53 -71 -90 -108 -122 -128 -131 -135 -138 -140 -142 -144 -145 -147 -148 -149 -150 -151 -152 -153 -153 -152 -150 -148 -146 -144 -141 -137 -133 -127 -122 -107 -75 -29 29 106 203 323 463 616 767 887 915 892 753 534 296 94 -35 -88 -107 -117 -125 -130 -133 -136 -138 -140 -141 -142 -143 -144 -145 -145 -144 -144 -142 -141 -140 -138 -136 -134 -132 -129 -126 -123 -119 -116 -112 -106 -100 -93 -87 -81 -75 -68 -59 -46 -37 -32 -29 -27 -26 -24 -22 -21 -21 -21 -21 -21 -21 -22 -24 -26 -28 -31 -35 -39 -40 -38 -37 -36 -35 -34 -33 -32 -32 -31 -31 -31 -31 -32 -32 -33 -33 -33 -32 -32 -29 -26 -15 26 89 175 288 421 559 678 723 710 590 356 61 -229 -454 -563 -578 -544 -486 -472 -469 -467 -463 -453 -425 -375 -319 -266 -217 -170 -123 -73 -21 29 72 106 125 135 140 143 147 151 156 161 167 177 192 206 216 225 235 245 257 272 287 301 316 328 341 354 369 381 390 400 409 421 434 448 456 462 466 470 471 471 470 466 462 456 448 433 421 404 384 364 342 319 298 277 256 239 226 213 197 174 148 122 107 98 92 88 86 85 83 82 80 78 73 66 59 54 48 42 38 36 37 40 46 52 73 129 214 338 505 701 893 995 989 852 565 233 -50 -223 -263 -206 -114 -33 -4 1 7 11 15 17 18 18 17 15 13 9 6 2 0 -4 -12 -17 -18 -20 -21 -22 -24 -26 -27 -28 -30 -31 -33 -35 -37 -39 -43 -47 -51 -56 -61 -67 -78 -92 -99 -106 -114 -123 -136 -152 -161 -166 -171 -177 -183 -186 -188 -189 -190 -191 -191 -191 -191 -192 -192 -193 -193 -193 -193 -193 -194 -195 -197 -198 -201 -203 -212 -231 -239 -243 -246 -249 -251 -253 -255 -257 -258 -259 -259 -259 -260 -261 -265 -272 -276 -278 -280 -282 -285 -290 -295 -301 -311 -318 -326 -339 -357 -371 -379 -383 -387 -393 -401 -415 -432 -439 -443 -445 -447 -448 -448 -446 -443 -440 -438 -436 -433 -430 -428 -427 -428 -429 -432 -436 -444 -456 -460 -463 -465 -465 -461 -454 -442 -424 -412 -403 -393 -381 -367 -345 -316 -273 -207 -110 23 194 383 560 683 705 597 364 65 -218 -422 -505 -516 -484 -439 -413 -404 -400 -398 -398 -399 -399 -400 -401 -402 -403 -403 -403 -403 -402 -401 -399 -397 -395 -393 -390 -387 -381 -374 -364 -358 -351 -340 -327 -311 -297 -289 -283 -279 -276 -269 -258 -247 -232 -214 -199 -175 -151 -125 -98 -71 -45 -19 8 37 72 106 136 163 190 216 242 259 276 291 315 342 367 393 405 410 414 416 416 411 403 390 371 359 352 347 342 338 333 326 319 309 296 284 271 257 243 220 193 164 138 114 101 80 58 31 4 -17 -40 -68 -100 -135 -172 -207 -243 -277 -299 -307 -302 -288 -253 -204 -142 -65 23 121 227 346 492 673 875 1056 1154 1122 940 629 261 -60 -256 -296 -218 -88 35 123 176 211 238 266 275 278 280 270 257 248 245 243 240 249 262 280 294 302 309 316 322 329 336 342 346 350 354 356 357 358 360 361 362 364 365 367 369 373 381 391 405 421 432 440 449 459 474 492 505 510 513 515 516 518 519 521 522 524 524 525 527 530 528 520 509 495 468 433 395 358 323 294 269 239 203 170 146 130 113 96 71 49 37 27 18 10 0 -12 -21 -28 -23 -10 18 62 127 218 336 476 628 763 828 823 733 539 297 70 -89 -147 -152 -117 -82 -71 -75 -88 -116 -133 -137 -141 -144 -147 -149 -150 -151 -152 -153 -152 -152 -153 -155 -157 -158 -158 -158 -156 -153 -150 -148 -146 -148 -156 -163 -169 -172 -173 -173 -174 -175 -177 -178 -175 -170 -165 -161 -158 -154 -152 -150 -147 -140 -129 -120 -112 -104 -96 -84 -73 -65 -57 -49 -42 -40 -38 -36 -44 -49 -51 -53 -55 -57 -59 -61 -64 -66 -68 -69 -69 -69 -70 -72 -75 -78 -80 -81 -80 -77 -74 -69 -64 -58 -48 -41 -33 -25 -16 -6 3 9 13 14 15 16 17 18 21 25 30 37 50 59 66 73 78 81 84 87 91 94 97 98 99 101 104 107 108 106 103 101 98 98 102 110 122 138 154 173 184 190 195 199 201 204 206 206 206 207 208 211 214 218 222 225 229 230 229 226 222 219 214 209 203 198 192 188 189 193 197 202 198 196 194 189 182 175 171 166 161 156 152 147 135 112 99 90 83 75 67 54 36 20 9 0 -9 -22 -37 -55 -67 -74 -79 -81 -82 -81 -79 -74 -69 -62 -51 -32 -21 -15 -11 -6 -3 0 1 3 4 7 9 13 17 22 26 30 33 35 32 27 21 16 13 10 6 2 0 1 3 7 13 24 43 59 71 82 89 95 98 98 94 87 75 59 46 37 31 29 28 28 28 27 26 25 23 22 19 14 5 -8 -20 -34 -44 -51 -53 -51 -45 -37 -24 -14 -7 -2 5 15 35 74 142 247 392 579 792 988 1097 1099 998 758 463 186 -14 -105 -123 -111 -97 -92 -99 -127 -157 -173 -185 -199 -206 -209 -211 -214 -216 -217 -217 -218 -220 -222 -225 -226 -229 -234 -242 -248 -254 -271 -295 -304 -310 -314 -305 -294 -283 -274 -264 -251 -229 -208 -203 -200 -195 -191 -187 -183 -175 -162 -155 -150 -144 -137 -118 -93 -78 -67 -60 -52 -44 -37 -30 -24 -19 -16 -11 -1 11 20 25 29 31 34 35 35 33 28 23 19 13 7 1 -3 -9 -14 -20 -26 -29 -31 -32 -31 -31 -30 -30 -29 -28 -27 -22 -16 -13 -10 -6 -4 -2 0 0 0 0 0 -1 -1 -1 -1 -1 -3 -4 -7 -9 -11 -13 -14 -15 -16 -18 -22 -24 -18 -8 0 8 16 24 31 37 42 47 51 55 58 61 63 65 66 66 65 65 65 66 67 69 71 74 77 79 81 83 84 85 86 88 90 93 95 97 99 100 101 100 100 100 103 110 133 186 271 393 551 742 942 1106 1175 1101 880 564 237 -20 -147 -167 -140 -88 -76 -73 -86 -96 -102 -107 -112 -118 -122 -127 -131 -136 -141 -142 -140 -135 -130 -122 -110 -101 -94 -89 -85 -81 -78 -75 -73 -71 -69 -66 -64 -61 -57 -53 -49 -47 -46 -46 -45 -45 -45 -43 -41 -38 -35 -32 -29 -27 -25 -23 -19 -14 -11 -10 -9 -8 -6 -4 -4 -9 -13 -16 -19 -25 -31 -39 -54 -73 -88 -104 -120 -143 -163 -177 -183 -185 -187 -189 -190 -191 -192 -194 -197 -201 -203 -206 -209 -212 -214 -214 -213 -210 -207 -204 -202 -199 -197 -195 -192 -189 -187 -184 -181 -178 -175 -171 -164 -157 -152 -148 -140 -127 -112 -94 -59 -8 62 155 276 427 592 738 819 797 654 419 157 -54 -179 -213 -190 -165 -157 -158 -169 -184 -202 -210 -214 -217 -220 -222 -223 -224 -223 -221 -218 -215 -211 -205 -194 -183 -176 -172 -169 -167 -165 -162 -161 -159 -156 -153 -148 -142 -135 -127 -117 -107 -98 -91 -84 -79 -71 -62 -54 -46 -38 -29 -16 -2 11 21 25 27 28 30 31 33 33 34 34 33 32 30 28 26 23 21 16 7 0 -6 -11 -16 -21 -28 -40 -54 -61 -66 -68 -64 -55 -47 -37 -34 -34 -34 -33 -34 -43 -52 -61 -62 -55 -37 0 52 124 223 353 509 669 803 864 813 645 396 136 -61 -135 -141 -94 -57 -43 -44 -52 -60 -66 -72 -79 -85 -92 -95 -97 -98 -100 -99 -90 -80 -70 -64 -57 -50 -44 -40 -35 -36 -43 -48 -50 -53 -55 -56 -57 -55 -53 -49 -46 -43 -41 -38 -35 -33 -31 -29 -28 -27 -24 -22 -17 -6 5 13 20 28 35 37 38 39 40 40 41 40 38 34 29 19 5 -1 -5 -9 -15 -21 -34 -46 -50 -51 -52 -53 -53 -54 -55 -56 -57 -57 -57 -56 -55 -54 -53 -52 -50 -48 -46 -44 -43 -41 -39 -36 -34 -32 -29 -27 -24 -21 -16 -11 -4 20 72 155 279 445 637 819 926 931 847 635 377 136 -38 -117 -129 -116 -99 -94 -92 -88 -83 -78 -73 -70 -66 -62 -59 -57 -55 -54 -53 -50 -43 -35 -25 -13 -8 -6 -5 -3 -2 -1 -1 -1 0 0 0 0 0 0 0 1 1 2 3 3 3 4 4 5 5 5 6 6 7 8 10 11 13 15 20 26 32 37 40 43 45 45 44 42 39 33 21 9 2 0 0 -2 -3 -4 -4 -5 -5 -4 -5 -4 -3 -1 0 3 6 9 13 21 28 33 41 54 69 85 118 166 239 342 483 656 837 986 1051 987 774 442 63 -270 -486 -547 -483 -366 -243 -141 -71 -30 -2 10 15 18 20 21 22 23 23 24 24 26 27 28 29 28 26 24 22 20 19 23 32 42 54 61 70 84 93 97 100 103 106 109 111 114 121 133 144 157 171 186 195 199 202 204 206 208 209 210 212 213 216 220 220 213 203 191 180 167 153 138 119 105 96 89 80 67 53 38 25 14 6 -1 -4 -6 -8 -10 -12 -13 -14 -15 -15 -15 -14 -13 -12 -10 -8 -6 -4 -1 0 1 3 6 9 11 14 15 16 17 17 18 19 19 20 22 24 19 11 8 6 4 2 0 -1 -3 -6 -8 -10 -12 -14 -16 -19 -22 -26 -32 -37 -40 -43 -49 -56 -60 -62 -64 -66 -67 -68 -69 -70 -72 -73 -75 -76 -76 -77 -77 -78 -78 -79 -79 -80 -81 -81 -82 -82 -82 -83 -83 -83 -83 -83 -83 -84 -84 -85 -85 -85 -86 -86 -86 -86 -86 -86 -87 -87 -88 -90 -91 -93 -95 -96 -98 -99 -101 -104 -110 -113 -115 -116 -117 -119 -120 -121 -122 -123 -123 -123 -122 -120 -117 -115 -112 -109 -106 -101 -96 -94 -92 -92 -91 -91 -90 -89 -88 -87 -87 -87 -87 -88 -89 -90 -92 -95 -98 -105 -119 -128 -134 -140 -147 -166 -190 -216 -243 -270 -296 -322 … ]}

Labels(1:5)
ans = 5×1 categorical
     N 
     N 
     N 
     A 
     A 

Use the summary function to see how many AFib signals and Normal signals are contained in the data.

summary(Labels)
     A       738 
     N      5050 

Generate a histogram of signal lengths. Most of the signals are 9000 samples long.

L = cellfun(@length,Signals);
h = histogram(L);
xticks(0:3000:18000);
xticklabels(0:3000:18000);
title('Signal Lengths')
xlabel('Length')
ylabel('Count')

Figure contains an axes object. The axes object with title Signal Lengths contains an object of type histogram.

Visualize a segment of one signal from each class. AFib heartbeats are spaced out at irregular intervals while Normal heartbeats occur regularly. AFib heartbeat signals also often lack a P wave, which pulses before the QRS complex in a Normal heartbeat signal. The plot of the Normal signal shows a P wave and a QRS complex.

normal = Signals{1};
aFib = Signals{4};

subplot(2,1,1)
plot(normal)
title('Normal Rhythm')
xlim([4000,5200])
ylabel('Amplitude (mV)')
text(4330,150,'P','HorizontalAlignment','center')
text(4370,850,'QRS','HorizontalAlignment','center')

subplot(2,1,2)
plot(aFib)
title('Atrial Fibrillation')
xlim([4000,5200])
xlabel('Samples')
ylabel('Amplitude (mV)')

Figure contains 2 axes objects. Axes object 1 with title Normal Rhythm contains 3 objects of type line, text. Axes object 2 with title Atrial Fibrillation contains an object of type line.

Prepare Data for Training

During training, the trainNetwork function splits the data into mini-batches. The function then pads or truncates signals in the same mini-batch so they all have the same length. Too much padding or truncating can have a negative effect on the performance of the network, because the network might interpret a signal incorrectly based on the added or removed information.

To avoid excessive padding or truncating, apply the segmentSignals function to the ECG signals so they are all 9000 samples long. The function ignores signals with fewer than 9000 samples. If a signal has more than 9000 samples, segmentSignals breaks it into as many 9000-sample segments as possible and ignores the remaining samples. For example, a signal with 18500 samples becomes two 9000-sample signals, and the remaining 500 samples are ignored.

[Signals,Labels] = segmentSignals(Signals,Labels);

View the first five elements of the Signals array to verify that each entry is now 9000 samples long.

Signals(1:5)
ans=5×1 cell array
    {[-127 -162 -197 -229 -245 -254 -261 -265 -268 -268 -267 -265 -263 -260 -256 -253 -249 -247 -245 -243 -241 -238 -236 -234 -232 -231 -230 -229 -229 -229 -229 -230 -230 -230 -229 -229 -227 -225 -221 -218 -215 -213 -213 -213 -212 -211 -210 -209 -206 -203 -201 -198 -198 -200 -204 -210 -216 -224 -233 -243 -253 -262 -270 -275 -281 -286 -291 -292 -289 -282 -273 -264 -259 -255 -250 -246 -241 -237 -233 -229 -226 -222 -219 -216 -213 -209 -204 -195 -187 -179 -172 -169 -166 -164 -161 -159 -157 -156 -154 -153 -153 -154 -155 -157 -159 -160 -162 -164 -166 -167 -169 -170 -171 -174 -177 -177 -171 -158 -121 -66 11 109 219 331 434 519 575 593 578 533 440 329 213 99 -3 -88 -153 -189 -210 -222 -230 -237 -243 -248 -253 -256 -260 -263 -266 -267 -266 -264 -259 -254 -249 -244 -238 -231 -224 -216 -207 -199 -191 -183 -176 -170 -164 -159 -155 -150 -143 -137 -129 -122 -114 -104 -92 -77 -64 -52 -39 -27 -14 -1 9 18 26 34 42 49 53 56 58 61 64 67 70 72 73 73 73 72 71 69 66 62 58 53 49 45 39 30 21 14 7 0 -7 -13 -14 -10 -4 0 2 5 7 10 14 18 22 25 28 30 31 32 33 35 37 39 41 42 43 45 47 49 52 54 56 59 61 65 68 73 78 87 96 103 106 107 109 110 111 112 113 113 112 111 110 110 109 110 110 110 110 111 112 114 115 117 118 119 121 122 124 126 129 132 136 140 144 148 155 163 167 169 170 171 172 174 176 178 180 182 185 188 192 195 198 201 204 208 212 214 212 208 203 198 194 190 186 182 177 174 171 170 170 171 172 175 179 183 189 195 208 239 302 377 461 547 634 722 803 849 865 845 786 694 593 495 401 310 225 151 113 103 95 91 88 87 87 88 91 94 98 103 108 111 114 117 119 122 125 128 132 135 137 139 141 143 145 147 150 154 157 161 166 171 176 180 182 184 184 183 181 179 176 172 167 161 152 133 118 109 104 99 96 92 88 83 79 75 71 66 61 53 45 37 30 22 5 -22 -51 -77 -100 -125 -150 -178 -200 -214 -228 -242 -250 -254 -257 -259 -261 -264 -267 -270 -272 -274 -276 -278 -280 -283 -286 -292 -308 -323 -335 -344 -352 -364 -376 -388 -400 -412 -421 -430 -448 -475 -502 -526 -547 -570 -592 -618 -648 -680 -709 -729 -738 -745 -751 -754 -748 -736 -716 -689 -670 -658 -645 -632 -616 -597 -582 -568 -554 -535 -515 -496 -481 -472 -467 -464 -460 -457 -452 -447 -442 -435 -426 -412 -389 -376 -360 -337 -314 -289 -274 -267 -261 -256 -250 -245 -239 -233 -227 -221 -212 -202 -190 -172 -148 -130 -116 -104 -92 -78 -68 -60 -54 -49 -47 -45 -43 -41 -40 -38 -35 -33 -40 -52 -59 -66 -72 -76 -78 -77 -74 -67 -55 -18 33 102 193 310 441 567 669 718 735 711 638 511 355 196 56 -43 -96 -122 -144 -173 -195 -207 -215 -218 -215 -209 -202 -194 -186 -178 -168 -159 -152 -146 -141 -136 -133 -130 -126 -123 -119 -115 -111 -107 -103 -98 -92 -86 -80 -75 -69 -62 -53 -41 -26 -7 10 28 41 49 58 67 78 90 101 110 119 130 140 148 154 160 166 171 177 181 187 193 203 217 226 232 236 239 242 244 244 241 233 224 211 192 176 162 151 139 126 119 114 110 107 105 103 102 101 101 101 102 104 105 106 108 110 111 112 112 113 113 115 117 117 115 109 104 101 99 97 94 92 91 90 89 88 88 88 90 96 99 101 103 104 105 107 109 110 111 111 111 111 111 111 110 109 106 102 97 92 87 82 79 76 74 73 73 76 79 84 89 94 100 112 126 142 153 162 169 174 175 173 170 165 159 151 141 130 113 98 88 81 77 73 71 69 67 67 69 71 73 75 77 79 83 87 93 99 104 107 108 108 107 106 104 99 93 85 77 69 61 54 48 43 40 37 34 33 32 34 36 39 40 41 42 45 50 61 83 116 166 238 334 452 584 716 834 906 930 903 819 659 466 274 109 -8 -56 -74 -75 -69 -63 -58 -61 -78 -89 -98 -105 -103 -93 -81 -75 -70 -66 -61 -56 -52 -50 -51 -55 -59 -62 -61 -59 -56 -51 -47 -44 -44 -44 -44 -42 -38 -33 -28 -24 -22 -20 -17 -12 -5 2 14 27 38 50 62 72 82 91 97 98 97 97 97 97 99 99 98 96 93 90 85 78 70 61 51 42 36 31 27 22 17 11 3 -4 -11 -16 -20 -25 -30 -35 -39 -38 -34 -28 -20 -14 -8 -3 0 2 5 9 12 13 13 11 8 6 3 0 -1 -3 -5 -6 -6 -6 -5 -3 -2 -1 -1 0 2 5 7 -1 0 0 1 1 1 1 1 2 2 3 3 3 3 3 4 4 3 2 1 0 0 1 1 1 0 0 0 1 1 1 0 0 -1 -2 -3 -4 -6 -8 -9 -9 -9 -10 -9 -9 -7 -5 -3 -1 0 1 2 3 3 4 4 5 6 7 10 12 15 18 22 25 29 31 33 35 36 38 40 43 46 49 53 58 63 67 69 68 64 58 52 46 42 37 31 25 20 15 11 8 4 1 -3 -10 -20 -26 -30 -33 -37 -39 -35 -23 7 49 107 182 272 378 497 623 744 843 881 872 793 644 457 263 97 -18 -73 -90 -99 -104 -108 -112 -115 -118 -120 -122 -124 -125 -126 -127 -127 -129 -130 -130 -131 -134 -136 -135 -126 -115 -108 -102 -96 -92 -88 -85 -83 -81 -79 -78 -76 -75 -73 -72 -70 -68 -65 -62 -57 -52 -44 -32 -20 -6 6 20 31 42 53 64 71 75 78 80 82 84 86 86 85 82 77 71 66 60 53 45 35 25 15 7 -1 -8 -14 -17 -19 -20 -21 -22 -23 -24 -25 -27 -28 -29 -30 -32 -36 -37 -36 -34 -33 -31 -31 -31 -32 -35 -37 -40 -42 -47 -50 -49 -44 -40 -36 -31 -21 -11 -4 0 6 11 15 16 15 11 6 2 -1 -4 -8 -12 -16 -19 -22 -23 -23 -23 -22 -21 -18 -16 -13 -11 -10 -9 -8 -6 -4 -1 0 3 6 8 9 10 9 9 8 7 6 4 2 0 0 -1 -1 -1 -4 -7 -10 -10 -6 0 6 11 15 20 25 29 32 35 38 40 43 46 49 52 54 56 58 60 62 64 66 68 70 71 70 67 62 57 52 49 45 41 37 33 30 28 26 25 25 25 26 28 30 34 38 43 62 106 169 253 359 479 595 694 764 790 787 742 635 474 288 115 -4 -42 -52 -59 -63 -68 -72 -76 -80 -83 -86 -89 -92 -95 -97 -99 -102 -103 -104 -103 -102 -100 -97 -94 -90 -86 -81 -71 -64 -59 -56 -55 -55 -54 -53 -52 -50 -48 -47 -46 -45 -43 -41 -38 -34 -25 -7 1 7 14 21 29 42 60 69 75 79 81 82 80 76 71 67 64 60 57 54 51 49 46 44 41 38 35 32 28 22 15 10 5 1 -2 -6 -9 -11 -12 -13 -13 -13 -14 -15 -16 -17 -18 -19 -20 -23 -23 -19 -17 -16 -16 -15 -15 -15 -15 -15 -14 -13 -13 -12 -12 -11 -10 -9 -8 -6 -6 -5 -4 -2 2 6 8 6 1 -3 -6 -8 -11 -13 -15 -17 -17 -16 -14 -12 -10 -7 -2 0 0 -3 -6 -9 -8 -3 -1 0 1 2 2 3 3 4 4 4 4 4 3 3 3 3 2 1 0 0 0 0 -1 -1 1 3 4 6 7 10 13 17 21 26 30 34 36 38 40 42 44 47 49 51 53 56 62 74 80 84 86 88 87 86 82 77 59 34 20 12 7 2 -1 -5 -10 -16 -16 -9 -3 0 2 6 9 12 17 36 66 115 188 290 414 549 685 807 897 933 901 798 636 441 247 88 -21 -69 -87 -95 -103 -117 -131 -139 -130 -115 -103 -96 -91 -97 -103 -107 -110 -112 -110 -107 -103 -99 -95 -92 -92 -93 -96 -99 -102 -91 -81 -75 -71 -68 -67 -66 -65 -64 -63 -61 -60 -57 -53 -47 -35 -18 -3 10 18 22 26 33 40 47 52 57 61 64 67 72 78 79 80 81 81 82 79 74 68 61 52 42 33 23 15 9 5 1 -1 -6 -11 -16 -20 -22 -24 -25 -26 -27 -27 -28 -28 -29 -30 -31 -31 -31 -30 -29 -28 -27 -27 -25 -25 -25 -26 -28 -30 -33 -35 -31 -25 -22 -20 -19 -17 -15 -13 -10 -8 -6 -4 -3 -1 0 1 3 5 8 10 12 13 12 10 8 6 4 2 0 -1 -3 -5 -7 -7 -8 -7 -7 -6 -4 -3 -1 0 1 3 5 8 11 14 18 22 26 27 26 23 19 13 5 0 -4 -8 -10 -5 3 7 10 12 14 16 18 21 23 25 27 28 30 32 33 35 36 39 43 47 50 53 56 58 61 64 68 70 72 74 77 81 86 86 76 61 43 34 30 27 24 21 18 15 11 5 -1 -7 -12 -16 -20 -23 -21 -16 -1 19 46 80 129 199 296 415 549 683 803 889 925 899 803 645 453 262 103 -4 -62 -86 -102 -119 -135 -145 -151 -151 -143 -131 -118 -111 -107 -104 -102 -101 -100 -99 -97 -96 -96 -96 -96 -97 -98 -99 -100 -101 -102 -103 -104 -102 -99 -95 -89 -80 -69 -54 -40 -34 -30 -28 -24 -20 -16 -11 -6 0 3 8 26 50 63 71 76 81 84 87 91 96 95 87 82 79 75 71 67 63 57 46 29 16 7 -2 -11 -20 -27 -29 -31 -32 -33 -33 -34 -34 -34 -34 -34 -35 -35 -35 -35 -34 -34 -35 -36 -37 -37 -37 -37 -38 -39 -41 -42 -44 -45 -47 -50 -52 -55 -56 -55 -52 -49 -46 -43 -40 -36 -31 -26 -20 -15 -11 -8 -6 -3 0 0 1 0 0 -1 -3 -5 -8 -10 -12 -13 -15 -16 -17 -18 -18 -18 -17 -16 -15 -14 -12 -11 -9 -8 -6 -5 -3 0 2 5 7 7 7 6 6 5 4 4 2 1 0 -1 -1 -1 0 0 0 0 1 3 5 8 10 18 30 37 43 43 38 34 31 29 30 34 40 46 56 68 84 102 111 117 121 121 116 108 95 78 66 59 52 44 31 18 14 11 9 8 8 10 15 20 27 38 47 56 65 77 106 158 236 339 462 596 724 826 874 874 825 715 567 394 216 62 -41 -76 -75 -54 -42 -51 -76 -114 -137 -144 -135 -121 -102 -86 -78 -72 -67 -63 -61 -60 -59 -58 -57 -56 -56 -55 -55 -55 -55 -54 -53 -52 -52 -52 -51 -51 -50 -50 -48 -47 -45 -41 -31 -21 -11 -1 5 11 16 23 33 39 43 47 51 55 59 62 66 69 73 77 80 81 80 79 76 73 62 35 9 1 -4 -11 -16 -24 -34 -43 -48 -51 -53 -55 -56 -58 -60 -63 -66 -68 -71 -75 -80 -89 -104 -112 -116 -119 -122 -125 -126 -126 -123 -120 -115 -110 -102 -101 -106 -109 -111 -113 -115 -116 -116 -116 -116 -116 -116 -115 -113 -110 -124 -148 -175 -188 -195 -200 -203 -206 -209 -212 -216 -218 -221 -224 -227 -231 -235 -239 -242 -245 -248 -252 -258 -265 -273 -281 -289 -296 -303 -309 -314 -318 -321 -324 -326 -328 -328 -328 -325 -321 -317 -312 -306 -298 -289 -282 -275 -261 -238 -217 -202 -188 -170 -148 -127 -105 -83 -63 -49 -39 -22 1 19 26 31 30 20 13 7 2 0 2 8 18 49 87 125 142 152 159 158 145 127 103 90 84 79 74 70 65 57 28 -7 -31 -59 -78 -90 -89 -63 -8 65 149 232 306 372 431 464 463 422 329 207 75 -46 -149 -233 -300 -345 -365 -374 -379 -382 -386 -391 -397 -403 -413 -426 -427 -415 -404 -393 -383 -374 -369 -366 -364 -361 -357 -353 -350 -346 -340 -329 -306 -290 -281 -272 -263 -236 -202 -166 -142 -116 -88 -39 22 84 134 172 208 230 267 301 322 344 365 396 436 481 520 556 581 606 621 623 625 626 627 622 613 602 589 576 566 559 552 543 534 528 523 519 516 512 508 504 499 495 489 483 477 469 463 457 451 444 434 418 403 389 374 358 341 325 319 316 314 313 311 309 305 301 296 290 280 262 245 228 211 195 185 178 171 164 156 148 141 132 123 113 104 97 89 82 73 63 49 35 25 17 9 3 0 -3 -5 -7 -8 -10 -12 -14 -16 -18 -19 -21 -23 -25 -27 -30 -32 -34 -36 -38 -39 -41 -41 -42 -44 -45 -46 -47 -48 -49 -51 -53 -55 -56 -57 -58 -59 -61 -63 -64 -66 -68 -71 -75 -80 -83 -84 -82 -79 -75 -70 -66 -61 -57 -51 -46 -40 -34 -27 -20 -12 -1 7 7 1 -7 -19 -35 -47 -64 -85 -96 -101 -107 -110 -113 -115 -116 -116 -116 -115 -113 -110 -106 -99 -91 -61 -7 62 144 237 341 450 555 640 679 693 671 604 481 320 147 -12 -132 -205 -231 -240 -249 -248 -234 -210 -184 -173 -168 -164 -161 -159 -156 -153 -151 -149 -147 -145 -144 -143 -144 -144 -144 -144 -142 -140 -138 -136 -134 -133 -131 -129 -127 -124 -121 -118 -115 -111 -107 -101 -95 -88 -82 -77 -73 -68 -61 -47 -19 0 9 18 28 38 48 54 61 67 73 77 78 77 73 67 61 55 49 42 33 26 20 14 10 5 1 -2 -6 -10 -14 -17 -20 -22 -26 -31 -37 -42 -44 -44 -42 -39 -35 -31 -24 -18 -16 -18 -22 -23 -25 -26 -27 -29 -30 -33 -34 -35 -34 -33 -31 -29 -27 -26 -25 -24 -24 -24 -25 -26 -26 -27 -27 -26 -25 -24 -22 -21 -20 -21 -22 -24 -26 -29 -30 -30 -29 -29 -29 -28 -27 -25 -23 -22 -21 -21 -21 -22 -22 -22 -22 -22 -21 -19 -18 -16 -15 -15 -15 -16 -17 -18 -20 -22 -25 -28 -30 -32 -33 -35 -37 -39 -41 -43 -44 … ]}
    {[128 157 189 226 250 257 262 265 268 269 268 266 263 260 258 257 255 252 249 246 244 241 238 235 231 227 223 219 217 213 209 205 200 196 192 190 188 188 189 191 194 198 202 206 209 212 216 219 224 229 234 237 236 233 228 222 217 213 209 206 203 200 197 195 193 191 190 189 188 188 188 188 190 192 196 199 202 204 207 209 211 212 213 214 214 216 218 220 223 225 228 230 232 234 234 234 235 236 237 239 241 242 244 246 249 252 254 255 254 251 247 241 234 226 215 198 185 175 168 164 160 156 153 149 145 140 134 128 120 109 91 78 67 62 59 55 51 48 45 43 40 38 36 35 35 36 36 38 39 41 43 45 48 53 58 85 128 190 273 371 469 553 607 626 626 606 553 465 361 254 159 83 21 -12 -25 -29 -32 -34 -36 -38 -39 -40 -41 -42 -43 -42 -41 -40 -40 -40 -40 -41 -41 -41 -42 -43 -44 -44 -43 -41 -40 -39 -37 -36 -35 -34 -34 -33 -32 -31 -28 -25 -22 -18 -15 -11 -7 -4 -2 0 0 1 2 4 4 5 6 7 8 8 8 8 7 7 6 5 4 3 1 0 -2 -5 -7 -9 -12 -14 -15 -17 -20 -23 -27 -32 -38 -45 -51 -56 -61 -65 -70 -75 -81 -89 -98 -107 -114 -122 -129 -136 -142 -146 -148 -150 -151 -152 -153 -153 -153 -153 -154 -154 -153 -152 -149 -147 -144 -143 -143 -142 -140 -139 -138 -137 -136 -135 -134 -133 -132 -130 -129 -127 -124 -122 -120 -117 -115 -112 -108 -105 -102 -100 -98 -96 -95 -93 -91 -89 -88 -87 -87 -87 -87 -86 -86 -86 -86 -86 -86 -85 -82 -80 -78 -76 -76 -76 -76 -77 -76 -76 -74 -73 -71 -69 -67 -65 -63 -62 -62 -64 -66 -70 -75 -78 -75 -70 -68 -67 -66 -65 -64 -62 -60 -59 -58 -57 -57 -56 -56 -55 -54 -53 -52 -52 -51 -51 -51 -50 -50 -50 -50 -50 -50 -49 -48 -48 -47 -45 -44 -42 -41 -39 -38 -36 -35 -34 -32 -30 -28 -26 -23 -20 -17 -15 -13 -12 -11 -10 -8 -6 -4 -2 0 4 10 17 24 30 36 40 45 49 53 56 58 57 54 48 41 33 26 16 7 0 -5 -10 -13 -16 -19 -22 -24 -26 -28 -30 -31 -32 -32 -31 -30 -29 -29 -29 -28 -27 -27 -25 -23 -21 -18 -15 -11 -6 5 32 73 131 208 296 388 475 546 576 585 563 502 417 317 216 124 47 -13 -41 -49 -54 -56 -57 -56 -55 -53 -51 -50 -49 -48 -46 -44 -43 -42 -42 -43 -44 -45 -46 -48 -51 -53 -55 -56 -58 -59 -60 -59 -51 -41 -30 -23 -17 -12 -8 -4 0 3 6 9 12 15 17 19 21 23 25 29 34 39 45 49 53 58 62 67 71 75 79 83 88 93 98 102 107 112 116 117 114 107 97 87 76 60 46 37 30 25 20 16 12 6 0 -6 -14 -26 -44 -60 -76 -91 -109 -116 -120 -124 -128 -131 -134 -135 -137 -138 -139 -140 -140 -140 -139 -137 -136 -135 -134 -133 -131 -128 -125 -122 -119 -116 -113 -109 -106 -103 -101 -99 -96 -93 -90 -88 -86 -84 -83 -82 -81 -82 -83 -85 -87 -88 -88 -89 -91 -92 -93 -94 -94 -95 -97 -98 -96 -90 -83 -78 -74 -70 -67 -64 -62 -61 -61 -61 -63 -65 -68 -72 -74 -77 -79 -80 -82 -83 -85 -87 -89 -90 -90 -90 -90 -90 -90 -90 -90 -91 -91 -91 -90 -89 -88 -86 -83 -80 -76 -73 -69 -66 -64 -64 -64 -63 -62 -61 -60 -58 -56 -54 -52 -50 -48 -47 -46 -46 -46 -46 -46 -45 -44 -43 -40 -37 -35 -33 -31 -30 -29 -28 -27 -25 -24 -23 -22 -20 -18 -17 -15 -13 -10 -7 -3 1 10 30 47 57 66 72 76 76 71 63 54 44 29 17 6 1 -1 -4 -7 -10 -13 -16 -18 -20 -20 -21 -20 -20 -19 -19 -19 -18 -17 -17 -16 -14 -12 -9 -7 -4 -1 2 9 27 40 70 117 183 264 359 469 583 685 750 754 709 580 418 259 129 35 -1 -15 -16 -5 1 10 16 17 14 10 8 7 6 5 3 0 -2 -4 -4 -2 0 3 7 11 16 20 24 27 28 30 31 33 35 37 39 42 45 49 52 54 56 57 60 63 66 69 73 76 81 86 92 98 102 105 108 111 114 117 121 124 128 133 137 141 145 148 151 154 157 161 164 166 166 163 156 149 142 136 130 125 119 114 109 105 100 96 92 88 83 76 65 54 43 34 26 20 14 8 1 -4 -8 -11 -13 -16 -18 -20 -22 -23 -24 -26 -29 -31 -34 -36 -38 -41 -44 -47 -49 -52 -54 -57 -60 -64 -67 -69 -70 -69 -68 -65 -60 -55 -50 -45 -40 -38 -35 -33 -30 -28 -26 -24 -22 -20 -17 -15 -13 -11 -9 -8 -6 -4 -3 -2 0 0 2 4 5 7 9 10 13 15 18 19 20 22 23 24 25 26 26 26 27 28 29 31 31 33 34 35 36 38 39 40 41 44 47 51 54 55 53 50 44 38 31 23 11 -1 -10 -18 -30 -44 -62 -81 -99 -116 -132 -148 -165 -175 -181 -186 -190 -193 -196 -199 -203 -207 -210 -213 -216 -218 -222 -226 -230 -233 -234 -232 -228 -222 -216 -210 -204 -197 -191 -184 -178 -173 -168 -162 -156 -149 -143 -137 -131 -125 -119 -115 -111 -108 -105 -103 -100 -97 -94 -92 -91 -89 -87 -85 -82 -79 -77 -75 -72 -67 -61 -54 -47 -41 -34 -27 -17 -8 0 7 15 24 29 26 22 17 13 9 10 19 33 55 90 149 224 317 424 542 660 757 793 786 712 568 392 222 88 18 -2 -13 -21 -28 -33 -37 -40 -44 -48 -51 -52 -51 -45 -37 -30 -25 -22 -20 -17 -15 -12 -10 -8 -5 -2 1 5 9 13 16 19 22 24 27 29 31 34 36 39 42 45 48 50 53 56 58 59 61 62 63 64 65 66 68 70 73 75 77 80 82 86 91 96 100 105 108 110 112 115 117 118 120 121 123 124 125 125 122 116 107 97 85 65 49 44 41 38 36 35 34 33 31 30 30 30 30 30 29 29 29 30 30 31 31 30 30 30 31 32 33 33 33 33 33 33 32 32 32 32 32 32 33 34 36 37 39 40 40 40 40 41 42 43 45 46 48 52 56 59 62 64 65 65 66 66 66 66 66 67 68 69 70 71 71 71 70 69 68 67 65 64 63 62 61 61 60 59 58 57 56 55 53 52 51 50 50 50 51 51 50 50 50 50 50 50 50 51 52 53 54 56 58 59 61 63 64 66 67 68 69 70 71 72 73 72 72 71 69 67 65 63 60 57 55 54 52 51 49 46 42 39 35 31 27 23 19 16 14 13 12 10 9 7 5 3 0 -2 -5 -9 -11 -13 -14 -15 -15 -14 -13 -12 -10 -7 -6 -4 -3 -2 -1 0 3 5 8 15 21 22 17 11 7 5 2 0 -2 -4 -7 -10 -13 -16 -20 -25 -33 -40 -41 -38 -33 -30 -27 -25 -23 -22 -21 -19 -18 -16 -14 -12 -11 -11 -11 -10 -9 -8 -5 -2 2 12 37 81 149 237 343 466 599 723 800 805 752 613 441 279 149 53 6 -9 -17 -18 -12 -2 10 27 39 44 47 50 54 57 59 61 63 65 66 66 65 65 64 64 64 65 66 68 69 71 72 74 75 76 77 79 81 84 86 89 92 95 98 100 101 103 104 105 107 108 109 111 113 115 117 119 120 122 123 125 126 126 127 127 129 131 134 138 141 143 144 145 145 145 143 141 138 135 131 128 124 119 111 102 95 88 78 64 49 37 28 20 13 8 3 0 -3 -6 -8 -11 -13 -17 -20 -23 -26 -29 -32 -35 -38 -41 -44 -46 -48 -50 -52 -55 -58 -62 -71 -91 -107 -118 -128 -138 -145 -150 -154 -157 -161 -165 -170 -174 -178 -181 -185 -189 -192 -195 -197 -200 -202 -204 -205 -207 -208 -208 -209 -212 -216 -219 -219 -212 -204 -193 -180 -174 -172 -170 -169 -168 -167 -167 -167 -166 -166 -165 -164 -163 -162 -160 -159 -157 -155 -153 -151 -148 -145 -140 -133 -126 -120 -115 -109 -103 -92 -79 -76 -76 -75 -74 -74 -73 -73 -73 -73 -73 -74 -75 -78 -81 -86 -90 -100 -122 -145 -167 -180 -187 -192 -196 -200 -205 -210 -217 -229 -242 -251 -258 -263 -266 -266 -262 -255 -244 -224 -194 -168 -144 -122 -102 -87 -75 -59 -48 -40 -33 -29 -25 -22 -18 -10 6 27 46 61 72 85 93 98 102 105 106 105 103 100 95 91 85 75 65 54 48 43 38 34 31 28 26 25 25 26 26 26 26 26 26 26 25 24 23 24 26 28 31 33 36 40 44 50 67 101 156 235 338 458 582 693 777 804 794 716 580 420 262 134 52 29 32 56 74 80 82 84 86 88 90 92 95 99 103 106 109 112 114 116 118 119 120 122 124 127 130 133 136 138 139 141 142 144 146 148 152 163 177 183 186 189 191 193 195 197 198 200 202 204 206 209 211 212 213 214 215 216 217 219 222 226 230 233 235 235 235 234 233 232 231 230 229 227 225 223 221 219 215 211 205 196 178 161 142 124 112 100 87 67 54 45 38 31 24 18 11 0 -14 -27 -37 -45 -51 -56 -59 -61 -63 -66 -69 -70 -70 -69 -68 -67 -66 -65 -62 -59 -56 -54 -54 -56 -58 -60 -61 -63 -65 -68 -71 -73 -73 -72 -71 -70 -69 -67 -63 -72 -78 -81 -85 -88 -90 -90 -87 -82 -78 -74 -70 -67 -64 -60 -58 -56 -55 -56 -57 -58 -60 -62 -65 -69 -73 -78 -83 -85 -85 -81 -73 -63 -44 -16 2 16 28 34 40 44 46 47 44 36 26 17 9 0 -10 -17 -19 -19 -18 -17 -16 -16 -15 -14 -12 -8 -2 3 9 15 21 25 25 20 11 3 -2 -7 -11 -15 -19 -22 -26 -30 -33 -36 -38 -40 -42 -44 -46 -47 -48 -49 -51 -52 -53 -55 -55 -56 -56 -56 -55 -54 -53 -51 -48 -45 -42 -39 -35 -31 -26 -21 -17 -13 -9 -5 -1 1 3 5 7 10 12 15 18 19 21 21 21 21 19 17 13 10 7 3 0 -3 -7 -15 -22 -27 -32 -36 -39 -41 -44 -47 -48 -49 -50 -51 -52 -52 -52 -51 -49 -47 -45 -42 -38 -34 -29 -24 -15 4 22 66 132 223 333 451 562 650 679 672 604 478 325 178 50 -45 -81 -94 -93 -80 -75 -73 -70 -68 -66 -65 -65 -65 -64 -64 -63 -63 -63 -63 -62 -61 -59 -57 -55 -53 -52 -51 -50 -49 -48 -46 -45 -43 -40 -37 -32 -28 -24 -20 -16 -12 -9 -7 -5 -3 -2 0 1 4 7 12 16 21 26 32 37 43 48 55 61 67 71 74 76 78 79 81 83 85 86 88 88 89 90 90 90 89 86 82 78 73 68 63 58 53 48 43 37 31 24 17 10 4 -1 -5 -9 -14 -19 -25 -35 -43 -48 -51 -52 -53 -54 -55 -56 -56 -57 -58 -59 -59 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -50 -50 -50 -49 -47 -46 -46 -45 -46 -46 -46 -46 -45 -45 -46 -45 -44 -43 -41 -42 -46 -52 -60 -66 -69 -72 -75 -78 -81 -83 -85 -85 -85 -86 -86 -87 -88 -88 -89 -90 -92 -94 -95 -97 -97 -98 -98 -99 -100 -102 -104 -107 -110 -113 -118 -123 -129 -135 -141 -146 -149 -151 -153 -155 -157 -158 -159 -160 -161 -162 -164 -166 -168 -169 -170 -170 -170 -170 -168 -165 -160 -156 -151 -146 -141 -136 -131 -125 -120 -114 -107 -99 -93 -87 -82 -77 -72 -68 -63 -57 -48 -40 -31 -22 -18 -15 -13 -12 -10 -9 -8 -7 -6 -4 -3 -2 0 1 2 4 5 6 8 10 13 16 19 23 28 36 46 56 65 74 82 87 92 97 102 106 109 111 113 114 114 114 112 110 106 103 99 95 92 89 86 83 79 76 73 70 67 64 61 58 56 55 54 53 52 52 52 53 54 55 56 58 60 62 65 69 73 77 82 112 171 254 361 488 621 737 807 814 779 669 523 369 225 106 21 -1 -6 -11 10 40 63 69 74 78 76 58 45 36 29 25 25 32 41 50 58 67 76 84 92 98 103 107 109 110 111 112 112 112 113 113 113 114 115 116 118 120 121 123 125 127 129 132 135 139 144 149 156 163 170 177 182 187 191 195 198 201 203 204 205 207 209 211 214 215 217 217 218 218 217 216 215 212 209 206 203 199 195 185 162 142 127 107 94 86 79 73 67 63 60 57 53 48 40 30 17 11 7 4 0 -2 -5 -7 -9 -11 -13 -15 -16 -17 -17 -18 -18 -19 -19 -20 -20 -21 -22 -23 -24 -25 -24 -24 -23 -22 -22 -21 -19 -17 -16 -15 -14 -13 -12 -12 -11 -12 -13 -14 -15 -16 -16 -17 -18 -18 -19 -20 -20 -20 -20 -20 -21 -22 -23 -23 -23 -24 -25 -26 -27 -28 -28 -28 -29 -30 -31 -32 -32 -33 -33 -34 -36 -37 -37 -37 -37 -38 -40 -41 -41 -41 -41 -41 -41 -42 -43 -43 -42 -42 -42 -42 -42 -42 -41 -41 -41 -42 -43 -44 -45 -46 -46 -46 -47 -48 -48 -47 -46 -46 -47 -48 -50 -52 -54 -55 -56 -57 -59 -60 -61 -61 -61 -61 -62 -64 -65 -67 -67 -65 -59 -53 -47 -43 -38 -34 -29 -25 -21 -18 -15 -12 -9 -7 -5 -4 -2 0 4 8 11 11 10 6 1 -3 -8 -15 -22 -29 -37 -45 -53 -62 -70 -75 -77 -78 -81 -86 -85 -73 -67 -64 -62 -60 -59 -59 -57 -55 -52 -49 -47 -46 -44 -43 -39 -36 -31 -24 10 68 154 266 393 513 601 625 616 541 416 261 105 -21 -74 -93 -93 -79 -67 -56 -50 -56 -68 -76 -84 -92 -95 -94 -90 -85 -80 -76 -72 -68 -65 -60 -56 -53 -49 -45 -41 -38 -35 -32 -30 -27 -24 … ]}
    {[ 56 73 85 93 100 107 113 117 118 117 115 113 111 109 104 101 107 121 134 147 153 156 159 162 165 167 169 171 173 176 178 181 183 186 190 194 195 191 182 165 114 38 -55 -158 -244 -283 -295 -284 -252 -192 -113 -16 87 180 254 278 285 289 292 294 295 292 286 278 270 264 258 253 247 242 237 232 227 223 220 215 209 195 172 160 154 150 146 142 139 137 134 131 128 125 124 122 120 114 98 77 61 50 41 32 24 16 9 3 0 -5 -9 -14 -19 -23 -28 -35 -44 -52 -60 -68 -76 -83 -92 -100 -105 -105 -101 -94 -84 -68 -42 -24 -9 10 32 52 64 69 73 76 78 80 82 84 87 89 91 93 95 97 99 101 103 105 107 109 110 111 112 111 111 111 110 109 108 107 107 107 107 108 109 109 108 107 106 104 102 100 98 96 94 92 90 89 87 87 87 85 83 80 76 73 69 66 63 59 56 54 52 51 50 48 45 42 37 30 22 15 11 8 7 7 6 4 3 3 3 4 4 5 5 7 10 13 16 17 18 19 20 23 24 26 26 28 30 32 34 36 38 42 47 54 61 67 73 78 81 84 87 89 89 90 90 91 93 94 95 96 97 99 101 103 105 105 106 107 109 112 114 119 127 135 135 125 109 84 46 -14 -91 -180 -267 -329 -351 -352 -338 -300 -243 -174 -96 -14 62 127 148 154 157 160 162 163 160 153 146 141 138 135 132 129 126 124 123 122 120 119 117 116 116 115 114 112 111 110 108 107 105 103 102 100 97 95 92 88 79 68 59 51 42 33 24 14 4 -4 -14 -25 -40 -46 -49 -50 -50 -50 -49 -48 -48 -49 -50 -52 -53 -54 -55 -55 -56 -56 -57 -58 -60 -64 -69 -68 -60 -48 -32 -12 6 15 22 27 31 35 38 42 46 48 51 54 57 60 63 67 71 74 78 81 83 86 87 88 89 89 90 91 94 96 98 99 99 98 97 96 93 89 86 84 88 92 93 95 97 100 102 105 108 110 112 113 113 113 112 112 111 111 110 110 111 113 115 117 119 120 122 123 123 123 122 120 118 116 113 111 109 108 107 106 106 105 103 101 98 95 91 87 83 80 77 76 74 72 70 68 64 55 50 57 69 80 92 101 107 110 111 113 115 116 117 118 120 121 123 125 126 126 125 125 126 127 129 133 139 145 145 138 125 86 34 -36 -123 -217 -307 -380 -404 -393 -359 -254 -129 -10 89 159 192 210 222 227 223 210 192 161 125 104 94 87 89 106 115 119 124 129 133 137 140 142 144 145 146 146 146 146 146 147 149 150 148 141 131 119 100 80 68 60 54 50 46 42 38 35 32 28 23 16 5 -6 -19 -31 -43 -54 -64 -81 -106 -134 -166 -200 -234 -266 -298 -332 -364 -398 -426 -439 -444 -448 -452 -457 -463 -468 -474 -481 -492 -512 -535 -567 -606 -629 -643 -652 -656 -654 -647 -637 -620 -594 -571 -544 -524 -512 -502 -492 -481 -465 -446 -430 -407 -382 -358 -333 -307 -277 -256 -246 -239 -233 -227 -222 -216 -208 -198 -187 -173 -158 -139 -118 -105 -98 -92 -86 -81 -75 -70 -65 -60 -56 -51 -45 -40 -35 -30 -25 -20 -15 -9 -3 4 12 22 33 41 47 53 59 66 73 80 86 93 101 109 117 122 123 124 125 127 130 132 127 119 115 111 107 104 100 97 94 92 91 90 90 90 90 90 90 89 88 86 85 85 90 97 104 109 113 118 122 125 128 131 133 135 136 138 140 141 141 142 142 142 142 143 145 148 150 152 150 145 137 125 102 74 44 -11 -83 -177 -279 -363 -391 -382 -308 -184 -46 74 163 199 214 216 205 194 183 177 177 180 181 181 182 183 185 185 185 183 180 176 172 168 164 163 163 163 163 162 159 156 152 149 146 144 142 141 139 136 129 121 112 102 89 76 63 50 39 31 23 16 8 0 -6 -14 -21 -30 -38 -46 -51 -56 -60 -64 -67 -71 -73 -75 -75 -75 -73 -71 -69 -65 -62 -57 -53 -48 -42 -35 -26 -18 -10 -3 2 7 12 15 18 21 24 27 29 30 30 30 30 30 29 28 27 27 28 29 30 31 31 32 32 32 31 31 31 31 32 33 33 33 33 33 31 29 27 26 23 21 19 18 18 18 19 19 19 20 22 23 25 26 28 30 35 40 46 50 53 56 59 62 65 67 69 70 71 72 72 71 70 68 67 65 63 61 59 56 54 51 48 46 43 41 38 36 35 33 31 28 25 22 19 16 12 9 7 4 2 1 1 1 1 2 3 4 6 8 11 14 17 21 25 30 35 39 43 48 53 59 65 70 74 77 78 79 79 78 76 74 70 66 61 55 43 13 -40 -118 -217 -323 -417 -459 -474 -449 -373 -263 -144 -32 61 92 100 106 109 111 111 108 103 97 92 88 84 79 76 74 72 70 67 65 62 59 57 55 53 51 48 45 42 38 35 31 28 25 21 16 11 7 3 0 -2 -6 -11 -15 -21 -27 -38 -50 -64 -77 -85 -91 -96 -100 -105 -109 -113 -118 -123 -129 -134 -138 -142 -146 -152 -161 -171 -178 -178 -174 -166 -157 -145 -126 -107 -90 -76 -62 -50 -40 -33 -27 -21 -15 -6 1 8 13 18 23 26 30 34 37 39 40 40 39 38 37 35 34 33 31 30 29 28 27 24 21 20 21 23 26 28 32 37 42 45 44 39 34 30 25 20 17 17 19 22 25 26 27 28 30 32 33 35 36 36 36 36 35 34 33 32 31 31 31 32 33 34 34 34 34 33 33 33 33 33 33 33 34 36 37 38 39 40 40 41 42 42 42 41 43 48 47 30 21 15 9 3 0 -3 -4 -6 -8 -9 -10 -10 -10 -10 -10 -11 -12 -10 -2 8 19 32 43 52 56 58 61 64 67 69 71 73 75 75 75 75 74 73 71 69 66 62 58 53 49 23 -17 -76 -151 -236 -325 -411 -463 -481 -454 -372 -232 -83 41 123 150 160 163 154 138 129 122 115 109 104 101 99 98 97 97 98 98 99 99 99 98 97 95 94 90 86 81 76 72 68 65 61 57 54 50 46 42 39 35 31 26 19 5 -9 -23 -34 -45 -56 -65 -74 -84 -97 -111 -121 -129 -137 -144 -149 -154 -159 -162 -165 -168 -172 -175 -177 -177 -175 -170 -164 -156 -149 -139 -123 -110 -99 -93 -88 -85 -82 -78 -74 -70 -66 -63 -60 -58 -55 -52 -48 -45 -42 -40 -39 -37 -34 -31 -28 -26 -26 -27 -30 -33 -35 -36 -37 -39 -41 -42 -43 -45 -46 -49 -51 -53 -53 -53 -53 -54 -55 -56 -57 -59 -60 -62 -63 -64 -64 -62 -58 -53 -47 -39 -24 -9 -4 0 1 3 5 6 7 9 9 9 9 10 10 10 10 11 11 11 11 11 11 11 12 12 13 13 13 13 13 14 18 21 21 16 8 -2 -15 -16 -17 -19 -20 -22 -22 -19 -14 -9 -4 2 6 4 -1 -3 -6 -8 -11 -12 -12 -11 -9 -6 -3 0 4 12 19 25 30 35 42 47 45 41 38 35 32 30 30 33 37 41 46 54 55 45 31 12 -8 -31 -73 -125 -186 -252 -322 -389 -433 -448 -427 -359 -236 -88 46 137 163 159 131 116 111 109 108 106 105 103 101 99 95 88 75 66 62 60 60 66 72 77 82 86 88 87 84 80 75 71 66 61 55 49 42 37 33 30 26 23 20 17 15 13 10 6 0 -11 -22 -34 -45 -55 -64 -71 -81 -94 -101 -105 -109 -113 -116 -119 -120 -121 -121 -120 -119 -118 -115 -111 -106 -100 -87 -64 -46 -32 -18 -6 4 11 16 18 20 21 22 22 22 22 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 25 27 27 28 30 31 34 38 42 44 42 38 34 30 25 20 17 14 12 10 8 6 3 1 0 -1 -3 -7 7 17 22 27 31 33 34 32 29 25 21 17 14 12 9 6 3 0 -1 -4 -6 -8 -11 -13 -15 -17 -18 -20 -22 -23 -25 -27 -28 -30 -31 -32 -34 -36 -37 -38 -40 -41 -45 -54 -64 -76 -85 -89 -92 -95 -93 -80 -61 -39 -19 -2 6 11 15 18 18 15 10 5 1 -3 -8 -11 -12 -10 -6 -2 4 14 19 25 30 20 -11 -52 -100 -156 -220 -287 -348 -380 -390 -378 -340 -282 -209 -128 -43 30 84 112 123 126 123 115 100 87 83 81 79 75 70 63 49 27 11 1 -3 0 9 23 37 43 46 48 49 48 46 42 38 34 30 25 19 12 3 -6 -18 -27 -34 -39 -45 -50 -56 -62 -66 -69 -72 -75 -79 -82 -86 -90 -94 -99 -106 -113 -119 -126 -132 -140 -144 -139 -131 -124 -119 -114 -110 -105 -102 -97 -87 -68 -50 -36 -26 -14 3 17 27 31 30 26 21 15 16 26 34 41 48 52 55 60 65 65 57 52 49 45 42 41 42 44 46 48 49 50 52 54 56 56 54 51 47 43 40 35 30 25 23 22 23 24 25 25 25 25 26 27 27 28 28 29 29 30 30 29 28 27 26 26 26 25 25 27 29 31 32 32 32 28 24 19 16 12 8 4 1 0 -2 -4 -8 -10 -7 0 4 8 12 14 15 14 12 10 9 6 3 4 12 21 26 31 36 40 44 45 46 46 45 44 43 41 38 38 42 46 50 39 23 2 -34 -85 -148 -212 -266 -310 -322 -328 -320 -272 -198 -105 -13 64 123 159 172 172 158 121 86 67 57 51 48 45 42 40 36 31 24 24 29 34 38 42 44 42 36 29 25 20 15 12 10 10 10 11 11 12 14 3 -6 -12 -17 -24 -31 -37 -44 -50 -55 -61 -66 -72 -80 -88 -97 -104 -110 -115 -119 -123 -126 -129 -134 -137 -137 -133 -126 -121 -115 -109 -102 -94 -80 -60 -44 -32 -19 -11 -7 -3 0 2 5 9 12 16 21 31 53 69 78 85 91 96 99 102 105 109 111 111 109 105 100 95 91 87 82 77 72 67 62 56 51 48 45 44 42 40 39 37 35 33 32 30 29 27 26 25 25 25 24 24 24 24 24 25 25 25 25 25 26 26 26 26 25 24 23 23 22 20 19 17 16 15 13 10 6 1 -4 -8 -12 -14 -16 -17 -18 -18 -18 -17 -17 -18 -19 -19 -18 -14 -9 -5 -2 2 6 10 13 14 13 13 13 12 11 9 8 10 17 24 32 37 40 44 47 30 0 -27 -71 -116 -169 -222 -278 -338 -401 -442 -456 -433 -366 -248 -107 15 70 90 90 78 66 53 35 21 10 3 2 2 1 1 0 0 0 0 0 0 0 1 2 3 3 3 3 2 2 1 0 -1 -3 -4 -6 -8 -10 -12 -14 -17 -21 -25 -29 -35 -41 -47 -53 -59 -64 -70 -75 -80 -84 -87 -90 -93 -97 -104 -114 -127 -134 -138 -142 -145 -146 -147 -148 -147 -145 -142 -138 -134 -127 -118 -100 -83 -65 -47 -36 -26 -17 -7 4 13 20 27 33 39 44 47 50 52 54 57 59 60 61 63 65 66 67 67 67 67 67 67 69 69 70 72 77 69 62 56 52 50 51 55 61 70 80 84 87 91 91 83 76 69 64 63 68 75 87 104 111 116 120 123 121 116 111 107 103 100 97 94 90 85 81 77 73 67 58 46 32 24 18 13 9 5 1 -2 -4 -6 -7 -8 -10 -12 -17 -23 -32 -37 -42 -46 -49 -48 -45 -39 -33 -25 -15 -6 0 3 6 9 11 13 15 16 17 17 17 17 16 14 12 10 7 2 -2 -8 -23 -51 -91 -139 -197 -260 -329 -398 -447 -451 -420 -317 -177 -33 79 141 162 151 134 107 73 50 37 29 40 58 75 82 88 90 85 78 75 73 72 71 70 70 69 68 66 65 63 62 61 60 58 57 56 55 54 53 51 48 45 39 34 31 31 32 32 33 34 35 35 29 19 7 -8 -22 -31 -38 -43 -49 -56 -62 -68 -72 -77 -81 -85 -88 -89 -87 -85 -81 -76 -71 -63 -48 -33 -20 -10 -2 0 3 4 6 7 8 9 9 8 6 3 1 -1 -4 -7 -11 -14 -17 -17 -17 -16 -15 -13 -10 -6 -4 -9 -19 -26 -31 -36 -39 -41 -41 -40 -37 -33 -27 -21 -11 -6 -10 -18 -29 -43 -48 -50 -52 -54 -54 -52 -48 -42 -37 -35 -32 -30 -26 -23 -21 -18 -16 -15 -14 -14 -14 -15 -17 -18 -19 -21 -22 -23 -24 -24 -25 -27 -28 -29 -31 -32 -34 -37 -40 -44 -49 -55 -64 -69 -65 -58 -52 -45 -42 -44 -46 -48 -51 -53 -54 -53 -49 -44 -36 -20 -11 -7 -4 -1 0 3 5 7 9 12 15 18 23 31 38 44 53 62 74 85 95 95 83 68 48 17 -20 -70 -130 -198 -273 -346 -401 -408 -385 -294 -163 -30 78 126 140 149 152 152 150 146 138 111 75 62 58 55 53 52 51 52 52 54 56 59 61 63 66 69 72 75 76 76 73 70 66 63 60 57 52 48 42 35 28 21 13 5 0 -4 -8 -12 -16 -21 -27 -32 -39 -53 -73 -82 -86 -90 -93 -96 -98 -99 -100 -101 -101 -101 -101 -100 -99 -97 -95 -94 -91 -89 -85 -75 -64 -53 -41 -30 -22 -18 -14 -11 -9 -5 -2 2 6 9 12 14 17 21 23 25 27 28 28 27 26 25 23 20 18 15 14 13 11 10 9 9 9 9 8 8 7 6 6 6 6 6 6 6 7 8 9 9 9 10 10 10 7 2 15 24 28 33 36 38 39 38 38 38 39 39 39 39 38 38 37 37 37 38 37 37 37 38 38 39 39 39 38 37 36 36 36 35 32 27 24 22 20 19 16 13 11 8 6 4 3 1 0 -1 -2 -4 -6 -10 -14 -17 -17 -14 -10 -4 3 16 27 43 60 68 73 77 80 81 80 77 72 67 62 53 49 52 58 64 70 73 72 66 53 15 -36 -103 -180 -261 -336 -378 -392 -372 -313 -221 -119 -27 42 91 126 137 143 143 136 126 119 114 109 105 101 96 92 88 85 82 79 74 66 61 60 59 59 59 58 57 56 55 54 52 50 46 43 40 37 35 30 25 20 15 10 7 3 0 -3 -7 -12 -16 -21 -26 -33 -44 -54 -62 -76 -95 -104 -108 -113 -117 -119 -120 -117 -113 -108 -103 -98 -92 -84 -75 -65 -56 -48 -39 -32 -27 -25 -23 … ]}
    {[  16 17 17 19 20 21 21 21 19 16 14 12 11 9 7 5 4 4 7 10 13 16 18 21 24 28 30 30 28 27 25 24 23 22 20 18 16 15 16 17 19 21 24 27 33 37 35 30 27 25 22 20 18 16 14 11 8 4 1 -2 -4 -7 -11 -15 -19 -22 -23 -21 -19 -15 -11 -7 -2 4 12 21 29 33 36 38 40 42 44 46 48 49 51 53 54 55 55 55 55 56 57 59 64 67 64 59 45 10 -43 -113 -194 -278 -357 -409 -426 -406 -344 -232 -107 -1 43 54 62 68 72 75 76 77 75 74 72 70 67 64 60 55 51 49 48 47 44 43 42 45 49 52 56 59 60 59 55 49 38 26 22 20 17 16 15 15 14 14 14 14 15 16 17 17 10 1 -12 -28 -43 -59 -75 -93 -111 -120 -124 -127 -130 -131 -132 -133 -133 -133 -132 -131 -128 -125 -122 -119 -114 -106 -98 -92 -82 -67 -49 -35 -28 -23 -18 -10 -2 3 8 13 17 21 22 22 21 20 19 18 16 12 10 12 14 15 17 18 18 16 15 14 14 13 12 10 8 6 6 6 8 9 11 14 19 11 5 2 0 -3 -4 -4 -3 0 2 4 7 8 9 10 11 12 12 13 13 14 15 16 16 16 15 15 14 14 14 14 14 14 14 14 15 15 16 17 17 17 18 20 23 23 19 13 5 -5 -11 -13 -14 -16 -18 -19 -20 -21 -21 -20 -19 -18 -17 -14 -10 -3 10 25 38 45 49 52 56 61 66 70 75 79 83 83 81 78 74 69 63 60 64 70 74 79 83 83 78 70 47 5 -47 -105 -171 -246 -323 -388 -408 -399 -334 -223 -96 11 82 117 128 135 139 144 150 150 140 114 82 72 68 71 83 90 90 83 71 58 52 48 46 50 60 68 76 80 77 70 61 51 42 35 28 22 17 14 11 9 8 6 5 3 2 0 0 -2 -4 -8 -16 -34 -55 -74 -93 -109 -120 -127 -136 -144 -152 -160 -164 -160 -154 -149 -145 -141 -136 -131 -127 -122 -118 -114 -109 -104 -100 -94 -88 -78 -70 -62 -54 -47 -40 -34 -27 -20 -13 -6 0 5 10 13 15 17 19 21 22 23 22 20 19 17 16 15 14 13 12 11 11 12 13 15 16 17 18 20 22 23 24 23 20 17 12 3 -6 -8 -11 -10 -1 9 20 31 39 45 49 49 46 41 39 36 34 32 30 29 28 28 27 27 27 28 30 32 34 35 37 38 40 42 43 44 42 39 35 31 26 16 10 6 2 -2 -3 0 8 13 18 23 25 24 20 15 9 0 -9 -15 -20 -23 -26 -26 -24 -21 -16 -11 -2 6 17 32 38 40 42 43 44 45 46 47 49 50 51 52 53 53 54 55 57 60 63 62 58 49 23 -24 -87 -166 -260 -363 -458 -518 -521 -473 -352 -206 -60 57 132 152 160 160 150 136 119 103 86 75 70 67 64 61 59 58 56 54 51 48 47 47 49 52 54 57 61 63 59 50 40 27 17 12 9 7 5 2 0 -2 -5 -7 -9 -12 -15 -19 -23 -27 -31 -36 -46 -62 -75 -92 -114 -131 -140 -145 -149 -151 -151 -148 -144 -142 -140 -139 -137 -135 -133 -130 -128 -124 -120 -111 -93 -79 -71 -63 -55 -45 -34 -17 -2 9 19 26 28 29 30 31 32 34 35 36 37 38 40 41 41 42 41 40 40 39 39 40 40 40 40 41 42 42 43 43 42 41 41 41 40 39 39 38 37 37 38 37 35 35 40 44 47 49 51 51 50 47 44 42 40 38 35 33 32 32 34 38 41 44 45 47 49 51 54 56 58 59 58 58 57 57 57 56 54 51 48 46 44 42 38 32 27 21 16 14 12 9 7 5 3 2 0 -2 -6 -9 -13 -15 -18 -20 -24 -28 -32 -34 -34 -33 -32 -31 -29 -26 -20 -1 11 18 23 26 28 28 26 24 20 17 10 7 12 21 32 45 52 59 65 64 56 32 -12 -72 -148 -238 -338 -437 -506 -516 -493 -399 -268 -123 11 104 139 152 151 137 115 90 72 60 51 45 40 36 34 36 41 47 53 60 65 66 60 53 45 35 26 18 12 7 4 1 0 -3 -4 -6 -8 -9 -12 -13 -15 -17 -20 -24 -28 -32 -38 -47 -62 -72 -84 -102 -114 -119 -123 -127 -133 -137 -142 -148 -163 -180 -186 -190 -193 -194 -190 -183 -173 -161 -143 -126 -114 -106 -99 -94 -90 -86 -82 -76 -66 -53 -42 -32 -21 -10 0 7 14 18 22 24 25 25 25 26 27 28 28 28 28 28 29 30 29 29 28 27 28 29 29 29 29 29 29 30 31 31 31 30 30 30 31 31 31 31 31 32 34 35 36 36 37 38 40 42 44 46 47 51 54 58 61 62 62 60 58 56 54 51 45 40 39 45 53 62 73 79 83 87 92 91 80 72 66 61 57 53 50 47 45 42 40 38 36 34 33 31 29 27 25 24 24 22 21 19 16 10 7 14 25 31 35 38 42 45 49 52 55 58 60 63 67 71 77 83 86 84 79 74 69 65 60 55 48 41 30 10 -22 -77 -153 -243 -334 -417 -463 -479 -456 -386 -261 -110 30 124 156 166 153 133 103 86 79 74 71 68 66 63 61 58 56 53 51 49 48 46 44 41 37 31 24 20 17 15 13 12 10 8 6 4 3 0 -1 -4 -7 -10 -16 -28 -39 -49 -59 -71 -79 -84 -89 -95 -102 -109 -116 -123 -131 -142 -150 -154 -155 -156 -156 -157 -159 -160 -161 -160 -156 -151 -145 -138 -128 -117 -107 -98 -90 -81 -72 -62 -53 -46 -40 -35 -30 -24 -19 -14 -9 -6 -2 1 6 12 17 22 25 30 34 38 41 41 39 35 31 26 23 21 17 14 11 9 8 9 12 15 18 21 24 26 27 29 30 32 33 33 34 35 36 36 36 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 36 36 35 35 34 33 32 31 30 28 27 26 25 23 21 19 17 15 12 9 7 5 3 1 0 0 0 0 0 1 1 3 5 7 10 12 15 18 22 25 29 32 36 40 46 52 57 62 65 67 68 68 68 68 67 64 60 56 52 32 -9 -70 -144 -228 -316 -394 -437 -452 -431 -366 -245 -102 26 80 95 103 109 113 117 122 130 140 126 102 79 70 66 63 62 61 61 60 60 59 58 56 55 54 54 53 52 50 48 45 41 37 33 23 14 6 -2 -12 -19 -25 -29 -31 -33 -36 -38 -40 -43 -45 -48 -52 -57 -66 -89 -120 -137 -142 -145 -148 -150 -149 -147 -143 -139 -137 -136 -134 -131 -129 -126 -124 -121 -119 -117 -115 -113 -110 -106 -99 -84 -72 -57 -39 -20 0 21 35 38 39 41 42 42 41 35 29 23 14 10 15 24 30 35 40 44 45 43 39 35 32 29 25 21 17 14 14 15 17 18 19 21 24 28 31 34 37 38 41 43 45 46 45 41 37 33 30 25 20 20 25 31 37 43 48 51 50 45 39 34 30 28 25 22 19 16 14 12 9 7 6 4 3 3 2 1 0 0 -1 -2 -2 -1 0 2 5 6 7 9 10 12 13 16 18 19 21 23 24 26 29 32 39 57 68 74 79 82 83 82 79 74 67 54 35 8 -30 -87 -161 -247 -334 -409 -453 -455 -422 -331 -212 -84 28 107 145 158 149 133 112 100 94 89 86 83 82 80 79 77 76 74 72 70 69 68 66 64 61 56 51 46 42 39 37 35 32 30 28 25 22 20 18 16 14 11 9 4 0 -6 -12 -20 -35 -61 -85 -102 -113 -118 -120 -122 -124 -126 -127 -128 -129 -130 -130 -130 -130 -130 -129 -128 -127 -126 -124 -122 -119 -117 -110 -94 -79 -69 -58 -48 -37 -20 -7 1 9 15 21 25 27 28 30 31 33 34 35 35 35 35 35 36 35 34 33 31 30 28 28 27 27 26 26 26 26 26 27 27 26 26 26 26 27 29 31 33 34 35 36 37 38 38 38 38 39 39 40 40 40 40 40 40 40 41 41 42 42 42 42 44 42 30 20 11 3 0 -4 -8 -11 -14 -15 -14 -9 -4 2 13 26 41 53 56 57 58 58 58 57 57 57 58 59 60 61 62 63 64 66 69 72 81 99 111 119 123 120 112 90 57 12 -43 -110 -186 -273 -368 -457 -511 -512 -465 -340 -179 -22 93 145 162 149 131 116 104 97 92 89 85 81 76 71 67 64 61 57 54 51 49 47 45 42 40 38 37 36 35 34 32 31 29 28 25 23 20 17 14 11 7 0 -14 -23 -27 -30 -32 -35 -39 -45 -53 -61 -71 -85 -94 -100 -107 -116 -129 -137 -143 -147 -151 -153 -155 -155 -157 -159 -163 -153 -136 -117 -101 -89 -74 -64 -57 -50 -44 -40 -36 -32 -25 -19 -13 -3 7 11 13 14 15 17 18 19 20 22 24 27 28 26 22 15 3 -4 -6 -7 0 6 10 13 16 18 18 17 16 13 12 9 5 5 10 13 15 17 19 21 20 19 16 12 9 5 0 -4 -5 -2 1 3 6 8 10 12 12 13 14 14 14 14 13 11 9 7 4 -1 -17 -30 -37 -43 -46 -49 -53 -58 -58 -50 -37 -23 -15 -10 -5 0 1 3 6 8 9 11 12 14 17 19 23 26 29 32 36 40 44 48 52 56 61 66 68 67 62 54 30 -14 -79 -161 -253 -349 -442 -516 -539 -531 -468 -355 -209 -57 74 155 168 173 164 137 109 94 78 64 55 49 47 49 52 54 55 57 58 59 59 58 58 57 56 54 51 46 38 23 17 15 12 10 9 8 8 8 8 8 8 8 8 9 10 11 11 11 12 12 13 13 12 8 2 -5 -20 -32 -39 -46 -52 -58 -63 -66 -66 -62 -58 -54 -51 -48 -45 -42 -39 -36 -29 -16 -7 -1 5 13 28 41 44 47 49 50 50 51 53 54 56 58 60 62 64 68 74 81 87 95 103 103 94 81 65 49 36 31 29 26 24 23 23 24 26 29 31 33 35 38 41 44 46 48 51 55 55 48 43 40 37 35 34 33 32 31 31 31 32 34 36 37 39 41 42 45 48 52 53 50 44 37 30 22 14 9 4 0 -3 -7 -10 -12 -13 -14 -14 -15 -16 -17 -17 -16 -12 -8 -3 0 6 12 16 21 28 41 50 56 59 57 53 50 47 44 42 42 43 46 51 56 61 70 75 73 67 48 13 -33 -96 -175 -263 -356 -445 -513 -546 -522 -443 -323 -180 -41 66 133 148 143 106 71 57 51 48 46 44 41 37 33 28 24 19 15 11 9 9 9 10 10 11 12 13 14 15 14 11 6 1 -6 -14 -22 -30 -37 -43 -47 -50 -56 -62 -63 -63 -64 -64 -64 -66 -69 -74 -80 -89 -99 -108 -117 -126 -139 -156 -167 -174 -178 -181 -182 -183 -184 -185 -187 -179 -164 -149 -135 -120 -110 -104 -97 -90 -78 -61 -48 -40 -32 -25 -20 -16 -13 -10 -8 -6 -3 -1 0 1 3 5 8 10 11 11 9 7 5 3 2 0 -1 -2 -3 -4 -4 -3 -1 1 3 6 9 13 17 20 22 21 20 17 14 11 8 4 2 3 6 10 13 15 18 19 21 23 24 25 26 28 29 31 36 34 21 12 5 0 -4 -5 -4 -3 -1 1 5 11 11 1 -7 -15 -19 -21 -22 -24 -25 -26 -27 -26 -23 -20 -15 -10 -2 5 11 17 22 27 32 37 44 51 56 61 66 71 70 60 45 26 15 10 6 1 -2 -5 -11 -33 -74 -141 -232 -329 -414 -457 -456 -406 -302 -173 -47 49 73 79 85 91 101 134 160 169 158 126 88 65 59 54 52 51 49 48 47 45 44 41 39 38 38 39 41 43 46 50 55 41 29 21 14 10 7 5 2 0 -1 -4 -7 -12 -17 -23 -32 -45 -56 -65 -72 -82 -93 -98 -102 -106 -109 -112 -115 -116 -117 -118 -118 -118 -117 -115 -113 -110 -107 -104 -100 -95 -81 -69 -59 -52 -46 -41 -36 -30 -22 -11 -3 2 8 17 26 31 34 37 40 43 46 48 49 50 50 49 49 47 44 41 37 34 32 31 30 29 27 26 25 24 24 23 22 20 19 18 18 18 18 18 17 18 19 21 24 26 27 27 28 28 29 30 30 29 30 31 33 36 38 39 40 40 41 41 40 37 34 31 27 24 21 17 11 5 0 -2 -5 -9 -15 -19 -15 -6 4 18 31 44 56 63 68 72 75 76 73 70 67 65 62 61 60 61 63 67 71 75 82 87 87 81 70 53 28 -10 -57 -110 -168 -231 -293 -323 -332 -308 -236 -125 -14 69 122 147 160 169 174 171 163 151 126 105 94 87 81 75 70 67 64 62 60 59 58 58 58 58 57 56 55 53 52 51 51 50 49 48 47 46 44 42 35 17 7 3 0 -2 -4 -6 -9 -12 -14 -17 -20 -24 -28 -39 -59 -71 -79 -84 -90 -94 -100 -107 -111 -108 -99 -92 -85 -77 -66 -55 -45 -35 -26 -19 -13 -9 -6 -5 -3 0 1 4 6 8 10 12 15 18 22 26 32 37 42 45 48 51 54 58 62 64 64 61 57 53 50 48 45 43 40 38 36 34 32 29 25 19 8 4 0 -3 -3 1 4 6 8 10 13 15 16 17 17 17 17 15 13 10 7 5 2 0 -2 -9 -17 -20 -21 -22 -25 -28 -19 -13 -9 -6 -3 -1 -1 -3 -6 -8 -10 -11 -14 -16 -19 -20 -20 -18 -13 -7 0 9 26 36 40 44 47 50 51 53 54 55 55 55 54 53 51 48 44 39 21 -11 -55 -109 -165 -215 -256 -287 -298 -292 -273 -204 -100 12 112 153 166 150 124 98 78 57 38 25 20 17 13 13 18 21 22 24 25 26 27 27 28 28 28 27 25 22 19 16 12 8 1 -10 -14 -15 -16 -17 -17 -18 -18 -19 -20 -22 -24 -26 -29 -33 -40 -58 -72 -81 -89 -98 -102 -105 -109 -112 -115 -117 -118 -119 -119 -119 -119 -118 -117 -115 -112 -109 -106 -103 -98 -86 -74 -60 -48 -43 -39 -36 -34 -31 -28 -23 -19 -15 -12 -8 -5 -2 0 0 2 4 6 7 9 10 13 16 18 20 19 17 15 12 9 6 4 6 8 10 11 13 15 16 18 20 22 24 26 29 32 33 34 33 31 29 27 26 24 21 19 20 23 28 33 41 46 49 52 55 57 55 50 43 33 20 18 17 15 13 15 20 24 27 30 32 32 31 29 28 26 22 20 20 26 33 43 54 61 63 65 67 69 70 71 71 71 71 70 70 69 68 66 64 60 61 73 82 91 97 98 95 87 66 21 -35 -99 -168 -239 -305 -346 -349 -317 -234 -127 -15 83 154 182 191 181 173 168 164 159 154 148 139 126 112 104 98 93 90 89 89 89 89 89 88 87 86 85 85 84 83 81 79 76 74 73 71 69 68 66 63 61 58 56 52 48 43 32 11 0 -6 -12 -17 -22 … ]}
    {[519 619 723 827 914 956 955 934 920 900 889 883 877 873 870 866 863 860 858 856 854 852 851 849 847 845 842 840 837 834 832 830 829 829 829 830 831 833 835 837 839 842 845 849 853 859 872 885 896 906 916 926 935 939 942 944 946 948 949 951 951 950 946 940 932 921 903 888 870 844 816 788 759 729 699 670 643 616 590 564 543 527 508 495 486 480 473 467 461 454 445 432 419 407 395 383 370 356 350 347 345 343 342 341 340 338 337 335 333 331 329 328 326 325 324 322 321 318 315 311 305 299 294 289 284 280 275 271 267 263 259 255 250 244 238 231 222 212 203 195 189 182 176 171 166 161 155 148 140 132 123 112 102 96 92 88 86 85 84 82 81 81 80 80 79 79 78 78 78 78 78 77 76 73 71 68 65 61 57 53 48 43 35 14 3 -2 -6 -10 -13 -17 -20 -23 -26 -28 -30 -32 -33 -34 -34 -35 -35 -36 -38 -40 -43 -46 -48 -49 -50 -51 -51 -52 -53 -54 -57 -63 -61 -47 -8 57 152 269 400 527 634 697 718 704 663 584 480 362 249 148 67 13 -4 -16 -25 -31 -34 -36 -38 -39 -41 -42 -43 -44 -45 -46 -48 -49 -49 -50 -50 -49 -47 -45 -43 -41 -40 -39 -37 -35 -33 -31 -29 -26 -21 -15 -9 -3 1 6 11 17 21 25 29 32 36 41 44 48 51 55 60 68 84 98 111 125 145 157 165 172 178 183 188 192 195 199 204 208 212 213 211 207 201 192 177 149 127 110 91 72 54 36 19 1 -16 -33 -50 -68 -83 -94 -104 -115 -125 -135 -145 -156 -168 -179 -186 -193 -198 -203 -207 -209 -210 -210 -209 -206 -203 -198 -192 -185 -176 -164 -153 -143 -135 -131 -128 -125 -122 -121 -119 -118 -117 -115 -115 -115 -115 -116 -117 -118 -120 -122 -124 -127 -129 -132 -134 -136 -139 -141 -143 -146 -149 -154 -159 -164 -169 -173 -178 -183 -188 -192 -196 -200 -203 -206 -209 -212 -213 -214 -213 -211 -208 -205 -201 -196 -190 -184 -177 -166 -156 -149 -144 -140 -138 -137 -136 -135 -135 -134 -133 -132 -131 -131 -130 -130 -129 -129 -130 -130 -130 -129 -129 -129 -129 -129 -129 -128 -128 -127 -127 -128 -128 -127 -126 -125 -124 -124 -123 -122 -121 -119 -118 -117 -116 -116 -114 -113 -111 -110 -108 -107 -106 -105 -104 -104 -104 -103 -103 -101 -100 -98 -96 -94 -91 -88 -84 -80 -77 -74 -70 -66 -60 -54 -48 -43 -39 -37 -34 -33 -32 -31 -31 -31 -29 -27 -26 -26 -28 -31 -36 -41 -48 -59 -59 -39 13 98 216 364 532 708 867 982 1027 981 844 652 442 260 133 63 31 6 -20 -34 -40 -45 -49 -52 -54 -55 -55 -54 -52 -49 -45 -41 -36 -31 -28 -26 -24 -22 -20 -18 -17 -17 -16 -16 -15 -14 -13 -12 -10 -9 -7 -5 -4 -3 -2 -2 0 0 0 1 2 4 6 8 11 14 17 21 34 45 54 63 72 81 93 108 124 141 158 175 192 206 218 225 228 229 231 233 235 236 232 224 214 203 188 176 165 155 144 133 123 111 97 80 63 45 25 4 -16 -34 -50 -64 -75 -83 -87 -89 -92 -94 -95 -96 -97 -97 -98 -98 -97 -95 -92 -88 -84 -80 -76 -72 -68 -65 -63 -62 -61 -59 -57 -56 -54 -53 -52 -51 -50 -49 -48 -48 -47 -47 -47 -46 -46 -45 -45 -45 -45 -45 -44 -44 -44 -44 -46 -47 -49 -51 -52 -53 -54 -56 -57 -58 -58 -59 -59 -60 -61 -62 -63 -65 -66 -67 -69 -70 -71 -72 -73 -74 -74 -74 -74 -75 -75 -75 -76 -76 -76 -76 -77 -77 -76 -76 -76 -76 -75 -75 -75 -75 -75 -74 -72 -71 -70 -69 -68 -67 -66 -65 -64 -64 -64 -64 -64 -64 -65 -65 -66 -66 -67 -67 -68 -69 -69 -69 -69 -69 -68 -68 -67 -66 -64 -63 -62 -61 -60 -58 -56 -54 -52 -49 -45 -40 -35 -30 -25 -22 -19 -17 -15 -14 -13 -13 -13 -11 -9 -5 -2 0 0 -1 -3 -5 -9 -14 -20 -7 33 99 195 324 482 662 850 1024 1134 1144 1082 898 657 417 232 135 100 84 70 52 27 -4 -19 -24 -29 -34 -38 -40 -42 -44 -46 -47 -47 -48 -47 -45 -43 -40 -37 -34 -31 -27 -23 -19 -15 -11 -8 -4 0 3 7 10 13 16 19 21 23 25 27 28 30 33 36 41 51 62 75 83 88 91 95 99 103 108 113 119 125 132 140 153 165 173 179 184 188 192 195 198 199 199 198 195 190 184 177 166 146 131 117 103 88 76 65 57 49 45 42 40 38 36 33 30 27 24 20 17 13 8 3 -1 -6 -11 -16 -20 -25 -30 -34 -38 -42 -46 -48 -50 -51 -52 -53 -54 -55 -56 -57 -59 -61 -62 -63 -64 -65 -66 -66 -67 -67 -67 -68 -69 -71 -73 -75 -77 -77 -76 -73 -68 -62 -56 -50 -42 -34 -31 -30 -29 -28 -28 -28 -28 -28 -28 -28 -28 -28 -28 -28 -29 -29 -29 -29 -30 -30 -30 -31 -31 -31 -31 -31 -32 -32 -32 -33 -33 -34 -35 -36 -36 -36 -37 -37 -37 -37 -37 -38 -40 -41 -41 -40 -37 -35 -33 -31 -30 -28 -27 -25 -24 -24 -23 -23 -23 -23 -23 -23 -24 -26 -27 -29 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58 -62 -66 -70 -72 -73 -72 -70 -67 -63 -59 -56 -52 -47 -42 -39 -37 -36 -35 -34 -33 -31 -30 -29 -28 -28 -29 -29 -30 -31 -33 -34 -29 -21 -19 -17 -15 -14 -12 -10 -9 -7 -5 -4 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -2 -1 0 0 1 2 3 4 4 5 6 6 6 7 6 6 6 6 8 10 11 13 15 17 18 19 21 24 29 49 103 186 304 455 636 831 1018 1160 1223 1185 1044 822 577 372 238 178 153 136 114 68 20 -16 -36 -43 -46 -48 -50 -51 -53 -54 -55 -57 -58 -59 -60 -60 -60 -59 -59 -60 -60 -60 -60 -61 -61 -61 -60 -59 -58 -57 -55 -54 -53 -51 -48 -46 -43 -36 -15 3 16 32 45 56 64 72 78 83 87 93 100 109 119 131 143 154 164 173 181 187 194 201 209 217 226 232 237 241 244 245 244 242 237 232 221 202 185 167 152 140 131 119 102 86 75 64 58 54 51 48 46 43 40 37 34 29 22 15 8 0 -10 -20 -31 -41 -53 -62 -68 -73 -79 -84 -89 -96 -105 -111 -114 -117 -119 -120 -122 -123 -123 -124 -124 -124 -123 -122 -119 -116 -112 -108 -103 -98 -88 -78 -71 -64 -57 -51 -46 -41 -38 -35 -33 -33 -32 -31 -31 -30 -30 -29 -29 -29 -29 -29 -29 -29 -30 -30 -29 -29 -29 -29 -29 -30 -31 -31 -32 -32 -33 -33 -33 -33 -34 -34 -35 -35 -36 -39 -41 -44 -46 -49 -50 -51 -52 -53 -54 -55 -55 -56 -57 -58 -59 -61 -62 -63 -63 -63 -63 -61 -59 -57 -54 -51 -48 -45 -43 -41 -39 -36 -33 -31 -29 -27 -25 -23 -22 -21 -20 -20 -20 -20 -20 -19 -19 -17 -16 -17 -23 -29 -34 -38 -43 -46 -47 -46 -42 -38 -34 -32 -30 -29 -27 -26 -25 -24 -23 -22 -21 -19 -18 -17 -16 -15 -14 -13 -11 -10 -8 -5 -3 0 2 8 14 19 21 23 25 27 29 30 32 33 32 29 25 22 20 19 17 15 14 12 10 9 8 8 7 7 8 8 9 10 11 12 13 14 15 16 17 17 19 20 21 23 24 28 32 31 27 22 18 13 9 7 6 7 12 18 25 33 44 52 55 57 59 62 64 60 50 39 26 22 17 14 23 52 108 192 310 468 655 853 1039 1178 1238 1195 1050 829 579 356 208 157 141 129 120 91 49 8 -28 -44 -52 -57 -59 -57 -48 -39 -35 -32 -29 -26 -23 -21 -19 -17 -16 -15 -14 -13 -12 -12 -12 -13 -13 -13 -14 -15 -16 -17 -17 -17 -17 -16 -16 -16 -15 -14 -13 -11 -9 -7 -5 -1 6 25 41 54 66 82 102 122 143 165 184 198 216 232 243 253 259 262 265 268 270 270 269 267 265 261 256 249 236 225 211 190 166 142 120 104 88 67 43 22 1 -14 -27 -40 -53 -65 -71 -74 -76 -77 -78 -79 -79 -78 -77 -75 -72 -68 -64 -59 -55 -52 -48 -46 -43 -41 -38 -37 -35 -34 -34 -34 -35 -36 -38 -40 -43 -46 -49 -52 -55 -57 -60 -62 -64 -66 -68 -70 -70 -70 -70 -69 -67 -66 -63 -61 -59 -56 -54 -52 -50 -49 -47 -45 -44 -43 -42 -41 -40 -39 -38 -37 -37 -37 -37 -38 -39 -41 -43 -46 -48 -51 -53 -55 -56 -58 -60 -61 -63 -65 -68 -71 -74 -77 -81 -83 -86 -88 -89 -90 -90 -91 -92 -94 -95 -97 -99 -101 -103 -104 -105 -104 -101 -98 -94 -89 -85 -80 -72 -65 -58 -53 -48 -45 -43 -41 -39 -37 -36 -34 -32 -29 -26 -23 -20 -18 -15 -12 -9 -6 -2 1 5 9 13 16 18 17 14 10 4 -1 -7 -15 -29 -40 -46 -51 -53 -56 -58 -61 -64 -66 -68 -68 -69 -70 -70 -70 -69 -68 -66 -64 -62 -60 -58 -55 -52 -49 -44 -36 -27 -19 -11 -3 5 16 24 32 36 39 41 43 45 47 49 50 52 53 56 59 74 119 195 307 459 643 848 1047 1204 1267 1256 1136 910 641 385 197 123 98 85 77 49 3 -46 -61 -64 -66 -67 -68 -68 -68 -67 -66 -62 -58 -54 -48 -40 -28 -17 -6 -1 0 2 3 5 6 7 8 9 10 12 14 15 16 17 18 19 20 21 23 25 28 34 46 57 67 74 79 84 88 92 96 99 104 111 123 137 151 165 180 194 205 216 226 238 251 266 275 282 288 291 291 288 282 275 266 251 235 219 203 184 158 127 104 85 65 44 24 6 -7 -19 -33 -49 -58 -65 -72 -77 -82 -85 -88 -90 -91 -93 -94 -95 -96 -96 -97 -99 -100 -100 -98 -93 -85 -77 -70 -66 -63 -59 -55 -52 -49 -47 -45 -43 -42 -40 -39 -39 -39 -39 -40 -40 -41 -43 -45 -47 -49 -51 -52 -54 -55 -57 -58 -59 -60 -61 -61 -62 -62 -62 -61 -60 -59 -58 -58 -58 -58 -57 -53 -47 -41 -38 -34 -30 -27 -25 -23 -22 -23 -26 -30 -35 -41 -46 -51 -54 -57 -60 -63 -65 -67 -69 -71 -73 -75 -76 -78 -79 -79 -79 -78 -77 -76 -74 -72 -69 -67 -65 -63 -61 -59 -57 -56 -54 -53 -52 -51 -50 -49 -47 -46 -44 -43 -43 -42 -42 -42 -42 -43 -44 -45 -47 -47 -47 -48 -48 -48 -48 -48 -47 -47 -46 -46 -46 -46 -46 -45 -43 -42 -41 -39 -38 -36 -34 -33 -31 -31 -30 -30 -29 -27 -26 -25 -24 -23 -22 -21 -19 -19 -19 -19 -19 -20 -20 -19 -18 -17 -16 -15 -13 -10 -7 -4 -1 0 2 5 7 9 11 12 14 16 17 19 21 23 24 25 27 27 28 28 28 27 27 26 25 23 22 21 20 19 18 16 15 14 13 12 12 11 10 8 7 6 3 -3 -9 -9 0 15 62 138 248 394 576 782 998 1194 1318 1330 1262 1057 791 524 310 181 137 124 109 94 69 27 -2 -17 -29 -39 -47 -54 -59 -65 -71 -76 -80 -81 -80 -75 -69 -63 -58 -53 -48 -43 -37 -31 -26 -21 -16 -11 -6 -1 2 6 10 15 19 24 29 34 38 43 49 55 62 69 74 80 85 90 94 99 103 107 112 117 122 128 135 144 159 173 189 202 215 225 233 239 243 247 250 253 255 256 254 251 245 237 229 218 201 186 173 158 140 123 106 89 70 50 31 11 -2 -13 -22 -29 -35 -40 -46 -53 -60 -69 -77 -83 -88 -92 -96 -98 -98 -96 -92 -87 -82 -79 -77 -75 -73 -71 -69 -67 -64 -62 -59 -57 -56 -54 -53 -52 -52 -51 -51 -50 -49 -47 -46 -46 -45 -45 -45 -45 -46 -47 -48 -49 -51 -52 -52 -53 -54 -54 -54 -54 -54 -55 -55 -56 -56 -57 -57 -57 -56 -56 -55 -54 -53 -53 -52 -53 -53 -54 -55 -57 -58 -60 -61 -62 -63 -64 -64 -65 -65 -67 -69 -72 -74 -76 -76 -76 -75 -73 -70 -68 -65 -63 -61 -60 -59 -59 -58 -57 -57 -56 -55 -53 -51 -49 -46 -43 -41 -39 -38 -36 -34 -33 -33 -33 -32 -32 -31 -29 -28 -27 -26 -26 -25 -25 -25 -25 -25 -25 -25 -25 -25 -25 -24 -24 -23 -22 -21 -21 -21 -21 -21 -21 -20 -20 -20 -20 -19 -19 -19 -18 -17 -17 -16 -16 -15 -14 -13 -13 -11 -9 -7 -4 -2 0 2 4 5 7 8 9 10 10 10 10 9 9 8 8 8 8 8 8 8 8 7 6 5 4 3 3 3 3 3 3 4 5 6 7 7 7 7 6 6 5 5 4 4 3 3 3 4 4 4 4 4 3 1 0 0 0 -1 -2 -2 -2 -2 -1 -1 0 0 0 1 2 4 6 8 10 13 16 21 27 32 35 37 39 40 41 42 43 43 44 44 44 45 44 44 43 42 40 39 38 36 35 34 34 34 33 33 32 30 29 27 26 24 23 21 20 18 15 7 0 1 7 17 46 113 215 355 529 726 927 1109 1217 1224 1148 940 665 387 174 83 52 64 82 94 75 42 11 1 -2 -5 -7 -8 -9 -11 -13 -14 -15 -16 -16 -15 -15 -14 -14 -14 -13 -12 -12 -11 -11 -10 -9 -8 -6 -5 -4 -3 -2 -1 0 1 2 4 6 8 14 22 29 36 44 53 62 72 80 89 100 115 133 158 184 203 218 238 251 259 266 271 272 272 272 272 272 271 271 271 271 271 267 261 253 244 233 222 213 197 175 153 129 107 91 76 56 31 12 -2 -16 -30 -45 -63 -80 -94 -104 -111 -116 -120 -123 -125 -126 -124 -119 -113 -106 -95 -79 -64 -58 -53 -49 -46 -43 -41 … ]}

Train Classifier Using Raw Signal Data

To design the classifier, use the raw signals generated in the previous section. Split the signals into a training set to train the classifier and a testing set to test the accuracy of the classifier on new data.

Use the summary function to show that the ratio of AFib signals to Normal signals is 718:4937, or approximately 1:7.

summary(Labels)
     A       718 
     N      4937 

Because about 7/8 of the signals are Normal, the classifier would learn that it can achieve a high accuracy simply by classifying all signals as Normal. To avoid this bias, augment the AFib data by duplicating AFib signals in the dataset so that there is the same number of Normal and AFib signals. This duplication, commonly called oversampling, is one form of data augmentation used in deep learning.

Split the signals according to their class.

afibX = Signals(Labels=='A');
afibY = Labels(Labels=='A');

normalX = Signals(Labels=='N');
normalY = Labels(Labels=='N');

Next, use dividerand to divide targets from each class randomly into training and testing sets.

[trainIndA,~,testIndA] = dividerand(718,0.9,0.0,0.1);
[trainIndN,~,testIndN] = dividerand(4937,0.9,0.0,0.1);

XTrainA = afibX(trainIndA);
YTrainA = afibY(trainIndA);

XTrainN = normalX(trainIndN);
YTrainN = normalY(trainIndN);

XTestA = afibX(testIndA);
YTestA = afibY(testIndA);

XTestN = normalX(testIndN);
YTestN = normalY(testIndN);

Now there are 646 AFib signals and 4443 Normal signals for training. To achieve the same number of signals in each class, use the first 4438 Normal signals, and then use repmat to repeat the first 634 AFib signals seven times.

For testing, there are 72 AFib signals and 494 Normal signals. Use the first 490 Normal signals, and then use repmat to repeat the first 70 AFib signals seven times. By default, the neural network randomly shuffles the data before training, ensuring that contiguous signals do not all have the same label.

XTrain = [repmat(XTrainA(1:634),7,1); XTrainN(1:4438)];
YTrain = [repmat(YTrainA(1:634),7,1); YTrainN(1:4438)];

XTest = [repmat(XTestA(1:70),7,1); XTestN(1:490)];
YTest = [repmat(YTestA(1:70),7,1); YTestN(1:490);];

The distribution between Normal and AFib signals is now evenly balanced in both the training set and the testing set.

summary(YTrain)
     A      4438 
     N      4438 
summary(YTest)
     A      490 
     N      490 

Define LSTM Network Architecture

LSTM networks can learn long-term dependencies between time steps of sequence data. This example uses the bidirectional LSTM layer bilstmLayer, as it looks at the sequence in both forward and backward directions.

Because the input signals have one dimension each, specify the input size to be sequences of size 1. Specify a bidirectional LSTM layer with an output size of 100 and output the last element of the sequence. This command instructs the bidirectional LSTM layer to map the input time series into 100 features and then prepares the output for the fully connected layer. Finally, specify two classes by including a fully connected layer of size 2, followed by a softmax layer and a classification layer.

layers = [ ...
    sequenceInputLayer(1)
    bilstmLayer(100,'OutputMode','last')
    fullyConnectedLayer(2)
    softmaxLayer
    classificationLayer
    ]
layers = 
  5×1 Layer array with layers:

     1   ''   Sequence Input          Sequence input with 1 dimensions
     2   ''   BiLSTM                  BiLSTM with 100 hidden units
     3   ''   Fully Connected         2 fully connected layer
     4   ''   Softmax                 softmax
     5   ''   Classification Output   crossentropyex

Next specify the training options for the classifier. Set the 'MaxEpochs' to 10 to allow the network to make 10 passes through the training data. A 'MiniBatchSize' of 150 directs the network to look at 150 training signals at a time. An 'InitialLearnRate' of 0.01 helps speed up the training process. Specify a 'SequenceLength' of 1000 to break the signal into smaller pieces so that the machine does not run out of memory by looking at too much data at one time. Set 'GradientThreshold' to 1 to stabilize the training process by preventing gradients from getting too large. Specify 'Plots' as 'training-progress' to generate plots that show a graphic of the training progress as the number of iterations increases. Set 'Verbose' to false to suppress the table output that corresponds to the data shown in the plot. If you want to see this table, set 'Verbose' to true.

This example uses the adaptive moment estimation (ADAM) solver. ADAM performs better with RNNs like LSTMs than the default stochastic gradient descent with momentum (SGDM) solver.

options = trainingOptions('adam',...
    'MaxEpochs',10,...
    'MiniBatchSize', 150,...
    'InitialLearnRate', 0.01,...
    'SequenceLength', 1000,...
    'GradientThreshold', 1,...
    'ExecutionEnvironment',"gpu",...
    'plots','training-progress',...
    'Verbose',false);

Train LSTM Network

Train the LSTM network with the specified training options and layer architecture by using trainNetwork. Because the training set is large, the training process can take several minutes.

net = trainNetwork(XTrain,YTrain,layers,options);

{"String":"Figure Training Progress (12-Jul-2022 11:48:30) contains 2 axes objects and another object of type uigridlayout. Axes object 1 contains 3 objects of type line. Axes object 2 contains 3 objects of type line.","Tex":[],"LaTex":[]}

The top subplot of the training-progress plot represents the training accuracy, which is the classification accuracy on each mini-batch. When training progresses successfully, this value typically increases towards 100%. The bottom subplot displays the training loss, which is the cross-entropy loss on each mini-batch. When training progresses successfully, this value typically decreases towards zero.

If the training is not converging, the plots might oscillate between values without trending in a certain upward or downward direction. This oscillation means that the training accuracy is not improving and the training loss is not decreasing. This situation can occur from the start of training, or the plots might plateau after some preliminary improvement in training accuracy. In many cases, changing the training options can help the network achieve convergence. Decreasing MiniBatchSize or decreasing InitialLearnRate might result in a longer training time, but it can help the network learn better.

The classifier's training accuracy oscillates between about 50% and about 60%, and at the end of 10 epochs, it already has taken several minutes to train.

Visualize Training and Testing Accuracy

Calculate the training accuracy, which represents the accuracy of the classifier on the signals on which it was trained. First, classify the training data.

trainPred = classify(net,XTrain,'SequenceLength',1000);

In classification problems, confusion matrices are used to visualize the performance of a classifier on a set of data for which the true values are known. The Target Class is the ground-truth label of the signal, and the Output Class is the label assigned to the signal by the network. The axes labels represent the class labels, AFib (A) and Normal (N).

Use the confusionchart command to calculate the overall classification accuracy for the testing data predictions. Specify 'RowSummary' as 'row-normalized' to display the true positive rates and false positive rates in the row summary. Also, specify 'ColumnSummary' as 'column-normalized' to display the positive predictive values and false discovery rates in the column summary.

LSTMAccuracy = sum(trainPred == YTrain)/numel(YTrain)*100
LSTMAccuracy = 64.4434
figure
confusionchart(YTrain,trainPred,'ColumnSummary','column-normalized',...
              'RowSummary','row-normalized','Title','Confusion Chart for LSTM');

Figure contains an object of type ConfusionMatrixChart. The chart of type ConfusionMatrixChart has title Confusion Chart for LSTM.

Now classify the testing data with the same network.

testPred = classify(net,XTest,'SequenceLength',1000);

Calculate the testing accuracy and visualize the classification performance as a confusion matrix.

LSTMAccuracy = sum(testPred == YTest)/numel(YTest)*100
LSTMAccuracy = 57.1429
figure
confusionchart(YTest,testPred,'ColumnSummary','column-normalized',...
              'RowSummary','row-normalized','Title','Confusion Chart for LSTM');

Figure contains an object of type ConfusionMatrixChart. The chart of type ConfusionMatrixChart has title Confusion Chart for LSTM.

Improve Performance with Feature Extraction

Feature extraction from the data can help improve the training and testing accuracies of the classifier. To decide which features to extract, this example adapts an approach that computes time-frequency images, such as spectrograms, and uses them to train convolutional neural networks (CNNs) [4], [5].

Visualize the spectrogram of each type of signal.

fs = 300;

figure
subplot(2,1,1);
pspectrum(normal,fs,'spectrogram','TimeResolution',0.5)
title('Normal Signal')

subplot(2,1,2);
pspectrum(aFib,fs,'spectrogram','TimeResolution',0.5)
title('AFib Signal')

Figure contains 2 axes objects. Axes object 1 with title Normal Signal contains an object of type image. Axes object 2 with title AFib Signal contains an object of type image.

Because this example uses an LSTM instead of a CNN, it is important to translate the approach so it applies to one-dimensional signals. Time-frequency (TF) moments extract information from the spectrograms. Each moment can be used as a one-dimensional feature to input to the LSTM.

Explore two TF moments in the time domain:

  • Instantaneous frequency (instfreq)

  • Spectral entropy (pentropy)

The instfreq function estimates the time-dependent frequency of a signal as the first moment of the power spectrogram. The function computes a spectrogram using short-time Fourier transforms over time windows. In this example, the function uses 255 time windows. The time outputs of the function correspond to the centers of the time windows.

Visualize the instantaneous frequency for each type of signal.

[instFreqA,tA] = instfreq(aFib,fs);
[instFreqN,tN] = instfreq(normal,fs);

figure
subplot(2,1,1);
plot(tN,instFreqN)
title('Normal Signal')
xlabel('Time (s)')
ylabel('Instantaneous Frequency')

subplot(2,1,2);
plot(tA,instFreqA)
title('AFib Signal')
xlabel('Time (s)')
ylabel('Instantaneous Frequency')

Figure contains 2 axes objects. Axes object 1 with title Normal Signal contains an object of type line. Axes object 2 with title AFib Signal contains an object of type line.

Convert the training and testing sets to gpuArray objects to execute the instantaneous frequency computations on the GPU. Apply the instfreq function to every cell in each set.

gpuXTrain = cellfun(@gpuArray,XTrain,'UniformOutput',false);
instfreqTrain = cellfun(@(x)instfreq(x,fs),gpuXTrain,'UniformOutput',false);

gpuXTest = cellfun(@gpuArray,XTest,'UniformOutput',false);
instfreqTest = cellfun(@(x)instfreq(x,fs),gpuXTest,'UniformOutput',false);

The spectral entropy measures how spiky flat the spectrum of a signal is. A signal with a spiky spectrum, like a sum of sinusoids, has low spectral entropy. A signal with a flat spectrum, like white noise, has high spectral entropy. The pentropy function estimates the spectral entropy based on a power spectrogram. As with the instantaneous frequency estimation case, pentropy uses 255 time windows to compute the spectrogram. The time outputs of the function correspond to the center of the time windows.

Visualize the spectral entropy for each type of signal.

[pentropyA,tA2] = pentropy(aFib,fs);
[pentropyN,tN2] = pentropy(normal,fs);

figure
subplot(2,1,1)
plot(tN2,pentropyN)
title('Normal Signal')
ylabel('Spectral Entropy')

subplot(2,1,2)
plot(tA2,pentropyA)
title('AFib Signal')
xlabel('Time (s)')
ylabel('Spectral Entropy')

Figure contains 2 axes objects. Axes object 1 with title Normal Signal contains an object of type line. Axes object 2 with title AFib Signal contains an object of type line.

Apply the pentropy function to every cell in the training and testing sets.

pentropyTrain = cellfun(@(x)pentropy(x,fs),gpuXTrain,'UniformOutput',false);
pentropyTest = cellfun(@(x)pentropy(x,fs),gpuXTest,'UniformOutput',false);

Concatenate the features such that each cell in the new training and testing sets has two dimensions, or two features.

XTrain2 = cellfun(@(x,y)[x y]',instfreqTrain,pentropyTrain,'UniformOutput',false);
XTest2 = cellfun(@(x,y)[x y]',instfreqTest,pentropyTest,'UniformOutput',false);

Visualize the format of the new inputs. Each cell no longer contains one 9000-sample-long signal; now it contains two 255-sample-long features.

XTrain2(1:5)
ans=5×1 cell array
    {2×255 gpuArray}
    {2×255 gpuArray}
    {2×255 gpuArray}
    {2×255 gpuArray}
    {2×255 gpuArray}

Standardize Data

The instantaneous frequency and the spectral entropy have means that differ by almost one order of magnitude. Furthermore, the instantaneous frequency mean might be too high for the LSTM to learn effectively. When a network is fit on data with a large mean and a large range of values, large inputs could slow down the learning and convergence of the network [6].

mean(instFreqN)
ans = 5.5551
mean(pentropyN)
ans = 0.6324

Use the training set mean and standard deviation to standardize the training and testing sets. Standardization, or z-scoring, is a popular way to improve network performance during training.

XV = [XTrain2{:}];
mu = mean(XV,2);
sg = std(XV,[],2);

XTrainSD = XTrain2;
XTrainSD = cellfun(@(x)(x-mu)./sg,XTrainSD,'UniformOutput',false);

XTestSD = XTest2;
XTestSD = cellfun(@(x)(x-mu)./sg,XTestSD,'UniformOutput',false);

Show the means of the standardized instantaneous frequency and spectral entropy.

instFreqNSD = XTrainSD{1}(1,:);
pentropyNSD = XTrainSD{1}(2,:);

mean(instFreqNSD)
ans =

   -0.3225
mean(pentropyNSD)
ans =

   -0.2408

Modify LSTM Network Architecture

Now that the signals each have two dimensions, it is necessary to modify the network architecture by specifying the input sequence size as 2. Specify a bidirectional LSTM layer with an output size of 100, and output the last element of the sequence. Specify two classes by including a fully connected layer of size 2, followed by a softmax layer and a classification layer.

layers = [ ...
    sequenceInputLayer(2)
    bilstmLayer(100,'OutputMode','last')
    fullyConnectedLayer(2)
    softmaxLayer
    classificationLayer
    ]
layers = 
  5×1 Layer array with layers:

     1   ''   Sequence Input          Sequence input with 2 dimensions
     2   ''   BiLSTM                  BiLSTM with 100 hidden units
     3   ''   Fully Connected         2 fully connected layer
     4   ''   Softmax                 softmax
     5   ''   Classification Output   crossentropyex

Specify the training options. Set the maximum number of epochs to 30 to allow the network to make 30 passes through the training data.

options = trainingOptions('adam',...
    'MaxEpochs',30,...
    'MiniBatchSize', 150,...
    'InitialLearnRate', 0.01,...
    'GradientThreshold', 1,...
    'ExecutionEnvironment',"gpu",...
    'plots','training-progress',...
    'Verbose',false);

Train LSTM Network with Time-Frequency Features

Train the LSTM network with the specified training options and layer architecture by using trainNetwork.

net2 = trainNetwork(XTrainSD,YTrain,layers,options);

{"String":"Figure Training Progress (12-Jul-2022 12:05:01) contains 2 axes objects and another object of type uigridlayout. Axes object 1 contains 7 objects of type patch, text, line. Axes object 2 contains 7 objects of type patch, text, line.","Tex":[],"LaTex":[]}

There is a great improvement in the training accuracy. The cross-entropy loss trends towards 0. Furthermore, the time required for training decreases because the TF moments are shorter than the raw sequences.

Visualize Training and Testing Accuracy

Classify the training data using the updated LSTM network. Visualize the classification performance as a confusion matrix.

trainPred2 = classify(net2,XTrainSD);
LSTMAccuracy = sum(trainPred2 == YTrain)/numel(YTrain)*100
LSTMAccuracy = 94.5471
figure
confusionchart(YTrain,trainPred2,'ColumnSummary','column-normalized',...
              'RowSummary','row-normalized','Title','Confusion Chart for LSTM');

Figure contains an object of type ConfusionMatrixChart. The chart of type ConfusionMatrixChart has title Confusion Chart for LSTM.

Classify the testing data with the updated network. Plot the confusion matrix to examine the testing accuracy.

testPred2 = classify(net2,XTestSD);

LSTMAccuracy = sum(testPred2 == YTest)/numel(YTest)*100
LSTMAccuracy = 91.5306
figure
confusionchart(YTest,testPred2,'ColumnSummary','column-normalized',...
              'RowSummary','row-normalized','Title','Confusion Chart for LSTM');

Figure contains an object of type ConfusionMatrixChart. The chart of type ConfusionMatrixChart has title Confusion Chart for LSTM.

Conclusion

This example shows how to build a classifier to detect atrial fibrillation in ECG signals using an LSTM network. The procedure uses oversampling to avoid the classification bias that occurs when one tries to detect abnormal conditions in populations composed mainly of healthy patients. Training the LSTM network using raw signal data results in a poor classification accuracy. Training the network using two time-frequency-moment features for each signal significantly improves the classification performance and also decreases the training time.

References

[1] AF Classification from a Short Single Lead ECG Recording: the PhysioNet/Computing in Cardiology Challenge, 2017. https://physionet.org/challenge/2017/

[2] Clifford, Gari, Chengyu Liu, Benjamin Moody, Li-wei H. Lehman, Ikaro Silva, Qiao Li, Alistair Johnson, and Roger G. Mark. "AF Classification from a Short Single Lead ECG Recording: The PhysioNet Computing in Cardiology Challenge 2017." Computing in Cardiology (Rennes: IEEE). Vol. 44, 2017, pp. 1–4.

[3] Goldberger, A. L., L. A. N. Amaral, L. Glass, J. M. Hausdorff, P. Ch. Ivanov, R. G. Mark, J. E. Mietus, G. B. Moody, C.-K. Peng, and H. E. Stanley. "PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals". Circulation. Vol. 101, No. 23, 13 June 2000, pp. e215–e220. http://circ.ahajournals.org/content/101/23/e215.full

[4] Pons, Jordi, Thomas Lidy, and Xavier Serra. "Experimenting with Musically Motivated Convolutional Neural Networks". 14th International Workshop on Content-Based Multimedia Indexing (CBMI). June 2016.

[5] Wang, D. "Deep learning reinvents the hearing aid," IEEE Spectrum, Vol. 54, No. 3, March 2017, pp. 32–37. doi: 10.1109/MSPEC.2017.7864754.

[6] Brownlee, Jason. How to Scale Data for Long Short-Term Memory Networks in Python. 7 July 2017. https://machinelearningmastery.com/how-to-scale-data-for-long-short-term-memory-networks-in-python/.

See Also

Functions

Objects

Related Topics