#!/usr/bin/python3

from random import randint

class Student:
    def __init__(self, id):
        self.id = id
        self.papers = []
    def assign_paper(self, paper):
        self.papers.append(paper)
    def __str__(self):
        return str(self.id) + ": " + str(self.papers)

class Paper:
    def __init__(self, id):
        self.id = id

def create_bundle_graph(n, k):
    students = [Student(x + 1) for x in range(n)]
    papers = [Paper(x + 1) for x in range(n)]

    while True:
        for i in range(k):
            inavai_pap = set()
            for j in range(len(students)):
                paper = None
                while True:
                    paper = papers[randint(0, len(papers) - 1)]
                    if paper.id == students[j].id:
                        continue
                    if paper.id not in inavai_pap and paper.id not in students[j].papers:
                        inavai_pap.add(paper.id)
                        break
                students[j].assign_paper(paper.id)
        # make sure not more than one paper is assigned to every two people
        success = True
        for i in range(n):
            for j in range(i + 1, n):
                cnt = 0
                for l in range(k):
                    if students[i].papers[l] == students[j].papers[l]:
                        cnt = cnt + 1
                    if cnt >= 2:
                        success = False
                        break
                if not success:
                    break
            if not success:
                break
        if success:
            break

    return students

@@ -1200,158 +1200,75 @@
 t = 
-0%0A                for l in range(k):%0A                    if students%5Bi%5D.papers%5Bl%5D == students%5Bj%5D.papers%5Bl%5D:%0A                        cnt = cnt + 1%0A    
+len(set(students%5Bi%5D.papers).intersection(set(students%5Bj%5D.papers)))%0A
     
@@ -1292,20 +1292,16 @@
 t %3E= 2:%0A
-    
         
@@ -1332,70 +1332,8 @@
 lse%0A
-                        break%0A                if not success:%0A
     

Update validation check for paper bundles.