(define (main args) (let* ([n (read)] [m (read)] [chv (string->vector (symbol->string (read)))] [adv (make-vector n '())] [ctv (make-vector n 0)] [md (+ 7 (expt 10 9))]) (let loop ([x m]) (cond [(zero? x) #t] [else (let* ([p1 (- (read) 1)] [p2 (- (read) 1)]) (vector-set! adv p1 (cons p2 (vector-ref adv p1))) (vector-set! adv p2 (cons p1 (vector-ref adv p2)))) (loop (- x 1))])) (for-each (^i (vector-set! ctv i (length (filter (^j (eq? #\A (vector-ref chv j))) (vector-ref adv i))))) (filter (^i (eq? #\C (vector-ref chv i))) (iota n))) (for-each (^i (vector-set! ctv i (remainder (apply + (map (^j (vector-ref ctv j)) (filter (^j (eq? #\C (vector-ref chv j))) (vector-ref adv i)))) md))) (filter (^i (eq? #\D (vector-ref chv i))) (iota n))) (for-each (^i (vector-set! ctv i (remainder (apply + (map (^j (vector-ref ctv j)) (filter (^j (eq? #\D (vector-ref chv j))) (vector-ref adv i)))) md))) (filter (^i (eq? #\P (vector-ref chv i))) (iota n))) (print (remainder (apply + (map (^j (vector-ref ctv j)) (filter (^i (eq? #\P (vector-ref chv i))) (iota n)))) md))) 0)