diff --git a/bin/p-score b/bin/p-score
index cd15d5ce30ccbfe08726e41bccd0042252b8a116..743f19a27cf05f3582a356faff1c462744aa367d 100755
--- a/bin/p-score
+++ b/bin/p-score
@@ -141,10 +141,11 @@ def write_html(round, tasks, contests, results):
             out.write(f'<tr><td colspan={num_cols}>\n\n')
 
 
-round = sess.query(db.Round).filter_by(year=args.year, category='P', seq=args.seq).one()
+round = sess.query(db.Round).filter_by(year=args.year, category='P', seq=args.seq).filter(db.Round.master_round_id == db.Round.round_id).one()
 print(f"Kolo {round.round_code()}")
 
-tasks = sess.query(db.Task).filter_by(round=round).order_by(db.Task.code).all()
+round_group_subq = sess.query(db.Round.round_id).filter_by(master_round_id=round.round_id).subquery()
+tasks = sess.query(db.Task).filter(db.Task.round_id.in_(round_group_subq)).order_by(db.Task.code).all()
 
 contests = (sess.query(db.Contest)
             .filter_by(round=round)