can you retype the correct version of this code? 
import csv
import random
import time
import os

# Define the domain
domain1 = "Product Assurance - Children's Products Label Review Procedure - US"
domain2 = "Parental Control Classification"
domain3 = "RISC WW KW Rule Writing E2E QA SOP"

# Define the qa_template
qa_template = {
    domain1: [
        ("What is the purpose of this procedure?", "The purpose of this procedure is to outline the review and approval process for CPSIA labeling requirements for children's products, this includes Producer's Markings, tracking labels, and Consumer Registration Cards. This procedure provides the user with definitions, labeling requirements for physical product AND product packaging, as well as acceptable and non-acceptable labeling examples. This procedure is part of the larger Product Assurance program."),
        ("What is the scope of this procedure?", "This procedure applies to all PA Brand Level Controls (BLCs) and Upstream Product Safety Controls (UPSC) in the US (MP1) involving Children's Products. The scope of this procedure is to be followed by PA Compliance Operations (C-Ops) associates. Please note Toys PA follows their own GRC, which incorporates elements of this procedure."),
        ("What is the CPSC?", "The Consumer Product Safety Commission is a United States regulatory body responsible for promoting the safety of consumer products by addressing 'unreasonable risks of injury'; developing safety standards; and conducting research into product-related illness and injury."),
        ("What is the CPSIA?", "The Consumer Product Safety Improvement Act of 2008, is a United States consumer product safety law that amended the Consumer Product Safety Act (CPSA) of 1972, providing the CPSC with new regulatory and enforcement tools, including the amending and enhancing of several CPSC statutes. The CPSIA includes provisions addressing lead, phthalates, toy safety, durable and infant toddler products, third-party testing and certification, tracking labels, imports, and a variety of other things."),
        ("What is a children's product?", "A consumer product designed or intended primarily for children 12 years of age or younger."),
        ("What is a durable infant and toddler product?", "A durable product intended for use, or that may be reasonably expected to be used, by children under the age of 5 years. These products are also referred to as 'Section 104' products, as CPSIA Section 104 requires the CPSC to study and develop safety standards for infant and toddler products."),
        ("What is a tracking label?", "A shorthand term used in place of the phrase 'distinguishing permanent marks' found in section 14(a)(5) of the CPSA. Manufacturers should not interpret 'label' to mean that all of the information has to be printed in one discrete location or label."),
        ("What is the role of Compliance Operations (C-Ops)?", "Responsible for verifying requirements are met."),
        ("What is the role of Standards and Risk Assessment (S&RA)?", "Maintains policy ensuring requirements are accurate and up-to-date. Reviews and answers compliance-related questions."),
        ("What is the role of the Product Assurance Program Team?", "Reviews and answers operational-related questions."),
        ("What are the CPSIA Section 103 labeling requirements?", "In the United States, children’s products are required to comply with labeling requirements set out in Section 103 of the Consumer Product Safety Improvement Act (CPSIA). Tracking label images must be provided by the SP for BOTH the physical product (principal component) and product packaging. ALL 'tracking labels' must be affixed and contain certain basic information, including: Manufacturer or private labeler (distributor or brand) name (only name is required, not address), Location and date of production of the product (date of production can be coded and not in traditional date format), Detailed information on the manufacturing process, such as a batch or run number, or other identifying characteristics, and Any other information to facilitate ascertaining the specific source of the product."),
        ("What is an acceptable alternate for Manufacturer or Private labeler for Section 103 requirement?", "Manufacturer code, distributor code, RN# (Run Number), Company website, Brand name, manufacturer name. (Brand and manufacturer name can be accepted if the brand or manufacturer attribute have the same name as in CSI)."),
        ("What is the CPSIA Section 104 product and outer package labeling requirements?", "In addition to the labeling requirements listed in 6.1, all Section 104 Durable and Infant Toddler Products must meet additional labeling requirements. These requirements include permanent markings, unlike 6.1 where information only needs to be affixed. Permanent Markings include markings that are molded (plastic), branded (wood), silk-screened (fabric) or ink-jetted into a product. Per CPSC guidance adhesive labels can also be considered permanent."),
        ("What is a 'permanent' mark by CPSC?", "The Commission considers a 'permanent' mark on a product to be a mark that can reasonably be expected to remain on the product during the useful life of the product. A mark on disposable packaging need only be permanent to the extent that it is durable enough to reach the consumer. As such, an adhesive label on a piece of disposable packaging might be sufficient for a packaging mark."),
        ("What are the durable infant and toddler product registration card requirements?", "In order to improve recall effectiveness, the US Congress has required that manufacturers of covered products: Provide consumers with a postage-paid product registration card with each product; and Include place the manufacturer/importer, U.S. contact information, model name and number, and the date of manufacture on each durable infant or toddler product registration card. Registration cards must be attached to the surface of each infant and toddler product so that the consumer will notice and can read the information after purchasing the product."),
        ("What is the purpose of a consumer registration card?", "For the customer to provide their contact information to the manufacturer, so that the manufacturer can notify the customer in the event of a recall."),
        ("What are the requirements for a consumer registration card?", "The registration card must match the template below. That is to say it must have a portion that the customer keeps, that has all of the pertinent information (make, model, mfr. date, etc). In addition, it must include a portion the customer fills out with their contact information that is postage paid (does not require postage stamp by cx) to send in for the manufacturer's records, so that if there is a recall in the future the manufacturer can reach out to the customer."),
        ("What is the review procedure for CPSIA Section 103 labeling requirements?", "Step 1: Is the ASIN a Section 103 product (see Appendix A for section 104 products)? If Yes, go to Step 2. If No, follow 6.2.1. Step 2: Did the SP provide images for both the physical product* (principal component) and product packaging? If Yes, Go to Step 2. If No, Reject. Step 3: Do the tracking labels on the physical product (principal component) and the product packaging contain the Manufacturer or private labeler (distributor or brand) name*? If Yes, Accept. If No, Reject."),
        ("What is the review procedure for CPSIA Section 104 product and outer package labeling?", "Step 1: Is the ASIN a Section 104 product (see Appendix A)? If Yes, go to Step 2. If No, follow 6.1.1. Step 2: Does the product and the product's outer packaging contain any one of the identifying information in 6.2 above? If Yes, go to Step 3. If No, Reject. Step 3: Is the Manufacturer or Distributor's location listed in the United States? If Yes, Approve. If No, Reject."),
        ("What is the review procedure for durable infant and toddler product registration card requirements?", "Step 1: Is the ASIN a Section 104 product (see Appendix A)? If Yes, go to Step 2. If No, follow 6.1.1. Step 2: Did the selling partner provide a live Product Registration Card? If Yes, go to Step 3. If No, Reject. Step 3: Is all information present as per table 2. Product registration card requirements? If Yes, Approve. If No, Reject."),
        ("What are some acceptable tracking labels?", "On the Self Product Examples - We can accept the tracking label considering the product is 'ON THE SHELF' product. i.e the product will be sold directly from the shelves without outer packaging (4 pcs in box and product will be sold separately from display). Like garments sold directly from the shelf and no packaging."),
        ("What are some unacceptable tracking labels?", "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging. Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed. Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."),
        ("What are some unacceptable product registration cards?", "Registration Card is unacceptable because it is not a live image; and does not match the template listed in Section 6.3. Registration Card is unacceptable because it is not a live image and does not show postage paid. Registration Card is unacceptable because it does not match the template shown in Section 6.3 and it only shows one side. Registration Card is unacceptable because it is a print out on standard sized paper, which is unacceptable. This is not post card sized, it only shows one side, and it does not include postage paid."),
    ],
    domain2: [
        ("What is the purpose of the Parental Control Classification procedure?",
         "The purpose of the Parental Control Classification procedure is to ensure that the products sold on Amazon comply with the provisions of law no.2022-300 of March 2, 2022, aimed at reinforcing parental control over internet access. This procedure helps reviewers determine if a product is classified as a terminal equipment and therefore fulfills the definition under the Parental Control initiative."),
        ("What is a terminal equipment?",
         "A terminal equipment is a connected object (fixed or mobile) offering access to the Internet for browsing purposes (direct or indirect). Examples include computers, mobile phones, tablets, gaming consoles, telephones, speakers, and watches."),
        ("What is considered browsing in the context of terminal equipment?",
        "Browsing refers to the act of navigating through the internet by accessing and viewing web content such as websites, images, videos, and other digital media. This includes web browsing, in-app browsing, and game browsing."),
        ("What are the criteria for a device to be considered in scope for Parental Control?",
        "To be in scope, a device must be a connected object (fixed or mobile) offering access to the Internet for browsing purposes (direct or indirect) and have an operating system."),
        ("What are some examples of in-scope devices?",
        "In-scope devices include computers, conference phones, e-book readers, game consoles (if they allow internet browsing), game controllers (if they have an operating system), laptops, MP4 players, smart GPS devices, smart monitors, smartphones, smart TVs, smart watches/fitness bracelets (if they have an operating system and allow internet browsing), tablets, and wireless speakers with a tablet attached."),
        ("What are some examples of out-of-scope devices?",
        "Out-of-scope devices include cameras with streaming/Wi-Fi connection, Chromecasts, classic versions of electronic devices with no internet connection, classic wristwatches, devices with only radio frequency function, GPS trackers for pets/phones, projectors, receiver dongles, security cameras, smart rings (NFC products only), smart watches/fitness bracelets (with no operating system and no internet browsing), spare parts, toy versions of electronic devices with no internet connection, Wi-Fi routers/extenders/kits, wireless controllers, wireless speakers without a tablet attached."),
        ("What is the process for evaluating ASIN classification?",
        "ASIN classification should be performed on the FR Marketplace. For active ASINs, the following sections of the Detail Page should be verified: Title, Bullet Points, Product Description, Product Images, Technical Details, and Brand. Refer to CSI and Media Central in case of doubt or if the ASIN is 'mislinked' or inactive."),
        ("What attributes should be checked in CSI for ASIN classification?",
        "Attributes to be checked in CSI include Title, Brand, Status, Bullet Point, Compatible Devices, Controller Type, Connectivity Technology, Item Description, Item Name, Operating System, Product Description, Product Type, Special Feature, Supported Internet Services, Supported Application, and Supports Bluetooth Technology."),
        ("What is the approach for borderline products?",
        "For borderline products, the recommendation is to proceed with an overestrictive approach if there is not enough information available to classify a given ASIN."),
        ("What is the clarification for smart watches?",
        "In-scope smartwatches must directly or indirectly (including via the paired device) give access to the Internet, apps, or pre-installed content. If a smartwatch does not have functionality allowing a direct or indirect connection to the internet, apps, or pre-installed content, it is out of scope. If a smartwatch cannot interact or operate independently from a phone, it is also out of scope."),
        ("What is the clarification for GPS/Navigation devices?",
        "In-scope GPS devices must directly or indirectly (including via the paired device) give access to the Internet, apps, or pre-installed content. Products with pre-installed app store (such as Google Play Store) that have the possibility to download other apps and browse YouTube for example will be in scope."),
        ("What is the role of the Product Assurance team in Parental Control Classification?",
        "The Product Assurance team ensures that the products sold on Amazon are safe and that Selling Partners are held accountable for ensuring that the products they sell meet all required compliance standards, including the provisions of law no.2022-300 of March 2, 2022 aimed at reinforcing parental control over internet access."),
        ("What are the examples of true positive (TP) devices?",
        "True positive devices include computers, conference phones, e-book readers, game consoles (if they allow internet browsing), game controllers (if they have an operating system), laptops, MP4 players, smart GPS devices, smart monitors, smartphones, smart TVs, smart watches/fitness bracelets (if they have an operating system and allow internet browsing), tablets, and wireless speakers with a tablet attached."),
        ("What are the examples of false positive (FP) devices?",
        "False positive devices include cameras with streaming/Wi-Fi connection, Chromecasts, classic versions of electronic devices with no internet connection, classic wristwatches, devices with only radio frequency function, GPS trackers for pets/phones, projectors, receiver dongles, security cameras, smart rings (NFC products only), smart watches/fitness bracelets (with no operating system and no internet browsing), spare parts, toy versions of electronic devices with no internet connection, Wi-Fi routers/extenders/kits, wireless controllers, and wireless speakers without a tablet attached."),
        ("What are the examples of borderline products?",
        "Borderline products include smartwatches and GPS/Navigation devices that may or may not have direct or indirect access to the internet, apps, or pre-installed content. For these products, additional criteria need to be considered to determine their classification."),
        ("What is the definition of a radio equipment?",
        "A radio equipment is an equipment that uses radio frequencies, in transmission or reception, for the propagation of waves in free space, for the purpose of radiocommunication, including equipment for receiving radio or television services. Examples include cell phones, car keys, modems, radio equipment, and remote controls. A radio equipment may also qualify as terminal equipment if it offers access to the Internet for browsing purposes."),
        ("What is the overestrictive approach for borderline products?",
        "The overestrictive approach involves classifying a product as in-scope if there is any indication that it might offer access to the internet for browsing purposes, even if the information is not explicit. This approach ensures that products are not mistakenly classified as out-of-scope when they might pose a risk."),
    ],
    domain3: [
        ("What is the purpose of the RISC WW KW Rule Writing E2E QA SOP?",
         "This document represents the quality audit (QA) standard operational procedure (SOP) for Regulatory, Intelligence, Safety and Compliance (RISC) program agnostic keyword (KW) rule writing (RW) end-to-end (E2E) across worldwide (WW) regions and nodes. The QA SOP establishes a standardized KW RW E2E checklist, using uniform metrics to measure process quality on all Operations (Ops) module of works (MoWs). This document intends to bring consistency and predictability to the workflow of a quality analyst and helps to ensure the quality of the outcome."),
        ("What is the purpose of the QA SOP?",
         "The QA SOP covers the defined steps for KW RW pre-deployment and post-deployment quality check (QC) and QA. The QC aims to identify non-compliant actions taken by RISC Ops team under ticket hygiene, rule settings, syntax writing/refinements and SR, through new rule (NR) creation, any rule updates (RUs) or rule refinements (RRs). These steps include the full guidance on the sampling methodology, quality parameter checklist, quality reporting mechanism and error rectification."),
        ("What is the background of the QA SOP?",
         "The RISC RW E2E quality audit framework (QAF) and current QA SOP, is a result of reorganizational structure, from program-level to RISC-level task procedure, also with the aim of removing the language dependency across WW regions and their marketplaces (MPs). The Quality Operations (Q-Ops) team in collaboration with Audit Insights Team (AIT) aims to identify cross-program defect trends, and collaborate with Ops on implementing CAPAs to mitigate errors and eliminate process gaps, encouraging best practice sharing across RISC Ops programs."),
        ("What is the ownership of the QA SOP?",
         "The Q-Ops team creates the QAF and ensure DMP adherence through current SOP. The SOP is reviewed and approved by WW Q-Ops RW single threaded leader (STL)."),
        ("What are the roles in the QA SOP?",
         [
            ("Role", "Name", "Designation", "Author", "Approver"),
            ("Sebastian Cojocaru", "Quality Specialist I", "Ilona Mocanu", "WW Q-Ops RW STL"),
         ]
        ),
        ("What are the RISC Ops programs in scope?",
         "The RISC Ops programs in scope are Cross Border Compliance (CBC), Product Safety Compliance (PSC) – Product Assurance (PA), Upstream Food Safety Control (UFSC), Upstream Product Safety Control (UPSC) – and Restricted Products (RP)."),
        ("What are the roles and responsibilities in the QA SOP?",
         [
            ("Role", "Responsibilities"),
            ("Rule Writer", "The rule writer creates and refines/updates rules (classes) received from Legal/Program Team, in order to catch restricted Amazon Standard Identification Numbers (ASINs) from the catalog, which are covered by the scope of the particular rule rationale. Through QAF, rule writer must acknowledge and provide 5 why analysis on the defects highlighted by quality analyst."),
            ("Sample Reviewer", "The sample reviewer performs the scrub audit (~1000 batch from output ASINs) before deployment, when the rule writer decides the rule syntax is ready, to have an overview of rule performance in terms of accuracy, as per KW RW procedure true positive (TP) targets. The sample reviewer role can be even taken by rule writer or a different associate, designated by Ops manager. Through QAF, sample reviewer must acknowledge and provide 5 why analysis on the defects highlighted by quality analyst."),
            ("Operations Subject Matter Expert (SME) or Process Expert (PE)", "Ops SME/PE ensures Ops SOP is up to date, seeks for process improvements, facilitates and performs deep dives on escalations. Through QAF, Ops SME/PE must validate appeal on errors that are not in line with the procedure and proceed with CAPA development and implementation, as per RCA, defect trends and error mitigation recommendations received from Q-Ops."),
            ("Operations Manager", "Compliance Ops manager ensures workflow for program level processes, drives alignment on existing workflows, manages deliverables through process controls."),
            ("Program Team (PT)", "PT ensures new and existing workflows for program level processes on a global scale, drives global alignment and standardization on processes WW, manages deliverables through process controls."),
            ("Quality Analyst", "Quality analyst performs QC and QA, identifies defects, has the ownership to validate 5 why analysis, track and close the defect feedbacks. Analyzes particular defect trends, prepares defect report and can proceed with CAPA request."),
            ("Quality Specialist (Q-Ops SME/PE)", "Quality specialist ensures QA SOP is up to date, seeks for process improvements, facilitates deep dives for escalations, validates errors and error types through the appeal process, works with quality analyst to define RCA, defect trends and error mitigation recommendations to showcase to Ops and collaborate with Ops in developing robust CAPAs."),
            ("Quality Manager", "Quality manager ensures new and existing workflows include a quality control component, facilitates deep dives for escalations to identify defects and provide RCA, drives alignment on quality processes for existing workflows, manages deliverables through process controls and support Q-Ops PoCs to collaborate with Ops on developing robust CAPA plans to mitigate defect trends."),
            ("Trustworthy Shopping Experience (TSE) Ops Analytics (TSEOA)", "TSEOA team is supporting Q-Ops in developing automated Datanet queries that eliminate or reduce the time on manual intervention in the Ops population (outflow) export, sample generation, work allocation and quality results reporting."),
         ]
        ),
        ("What is the RACI matrix for post-deployment?",
         "The Q-Ops team defines QAF RACI matrix in pre and post deployment QC phase, from the Ops output export till CAPA efficacy check. The roles for Ops, Q-Ops, PT and TSEOA PoCs are highlighted through distinct colors."),
        ("What is the frequency and task details for post-deployment?",
         [
            ("Frequency", "Task", "Task Details in Post-deployment", "Q-Ops PoC", "Ops PoC", "Ops Manager", "Q-Ops Manager", "PT", "Ops Leadership", "TSEOA"),
            ("Weekly", "1", "Export of week-1 population", "A/C", "-", "-", "-", "-", "-", "R"),
            ("Weekly", "2", "Week-1 QC sample generation and ingestion in Anduril", "A/C", "-", "-", "-", "-", "-", "R"),
            ("Weekly", "3", "Identification of the defects", "R", "I", "I", "A", "I", "I", "-"),
            ("Weekly", "4", "Tracking the defects", "R", "I", "I", "A", "I", "I", "-"),
            ("Weekly", "5", "Validating the defect", "C", "R", "A", "I", "C/I", "I", "-"),
            ("Weekly", "6", "Performing 5 why analysis for the identified defects", "C", "R", "A", "I", "I", "I", "-"),
            ("Weekly", "7", "Validating the quality of the 5 why analysis", "R", "C", "I", "A", "I", "I", "-"),
            ("Weekly", "8", "Correct the defects", "A/C", "R", "A", "I", "I", "I", "-"),
            ("Weekly", "9", "Generate the quality report in QuickSight", "A/C", "I", "I", "A", "I", "I", "R"),
            ("Monthly", "10", "Performing trend analysis on the defects and RCAs", "R", "I", "I", "A", "I", "I", "-"),
            ("Monthly", "11", "Assigning Ops owners for CAPA planning, design and implementation", "C", "R", "R/A", "I", "C", "I", "-"),
            ("Monthly", "12", "Assigning Q-Ops owners for CAPA planning, design and implementation", "R", "I", "I", "R/A", "C", "I", "-"),
            ("Monthly", "13", "Sharing recommendations resulting from the trend analysis", "R/C", "C", "R", "R/A", "I", "-", "-"),
            ("Monthly", "14", "CAPA Development", "R/C", "R", "R/A", "C", "C", "I", "-"),
            ("Monthly", "15", "Validating the CAPA quality", "R", "R/I", "I", "A", "I", "I", "-"),
            ("Monthly", "16", "CAPA Implementation", "C", "R", "R/A", "C", "C", "I", "-"),
            ("Monthly", "17", "Measuring CAPA effectiveness", "R", "I", "I", "A", "I", "I", "-"),
         ]
        ),
        ("What is the workflow for pre-deployment?",
         [
            ("Frequency", "Task", "Task Details in Pre-deployment", "Q-Ops PoC", "Ops PoC", "Ops Manager", "Q-Ops Manager", "PT", "Ops Leadership", "TSEOA"),
            ("Daily", "1", "Raise QC ticket request to Q-Ops/AIT", "I", "R", "A/C", "I", "I", "I", "-"),
            ("Daily", "2", "Day-0 QC inflow tickets allocation in Anduril/T-Corp", "R", "I", "I", "A/C", "I", "I", "-"),
            ("Daily", "3", "Identification of the defects", "R", "I", "I", "A", "I", "I", "-"),
            ("Daily", "4", "Tracking the defects", "R", "I", "I", "A", "I", "I", "-"),
            ("Daily", "5", "Correct the defects", "A/C", "R", "A", "I", "I", "I", "-"),
            ("Weekly", "6", "Generate the quality report in QuickSight", "A/C", "I", "I", "A", "I", "I", "R"),
            ("Weekly", "7", "Performing trend analysis on the defects and RCAs", "R", "I", "I", "A", "I", "I", "-"),
            ("Weekly", "8", "Assigning Ops owners for CAPA planning, design and implementation", "C", "R", "R/A", "I", "C", "I", "-"),
            ("Weekly", "9", "Assigning Q-Ops owners for CAPA planning, design and implementation", "R", "I", "I", "R/A", "C", "I", "-"),
            ("Weekly", "10", "Sharing recommendations resulting from the trend analysis", "R/C", "C", "R", "R/A", "I", "-", "-"),
            ("Weekly", "11", "CAPA Development", "R/C", "R", "R/A", "C", "C", "I", "-"),
            ("Weekly", "12", "Validating the CAPA quality", "R", "R/I", "I", "A", "I", "I", "-"),
            ("Weekly", "13", "CAPA Implementation", "C", "R", "R/A", "C", "C", "I", "-"),
            ("Weekly", "14", "Measuring CAPA effectiveness", "R", "I", "I", "A", "I", "I", "-"),
         ]
        ),
        ("What are the examples for post-deployment QC actions?",
         [
            ("Step", "RW Post-Deployment QC Action"),
            ("Step 1", "The Q-Ops/AIT PoC is ensuring that KW RW tickets' and SR Amazon Standard Identification Number (ASIN) weekly (week-1) population is automatically exported, along with QC samples generated in S3 Buckets, through Data Central queries owned by TSEOA team. If automation is not set in place these steps will be covered manually."),
            ("Step 2", "The Q-Ops/AIT PoC is ensuring that week-1 QC sample generated in S3 is ingested automatically and accurately in Anduril QC tool every week."),
            ("Step 3", "Quality analyst proceeds with QC on the sampled tickets and ASINs in the respective KW RW and SR Anduril Execution user interface (UI) workstream – custom template."),
            ("Step 4", "In case of QC parameters failed to pass, quality analyst proceeds with defect notification via DMP Simple Issue Management (SIM) template, for each parameter failed or ASIN incorrectly classified."),
            ("Step 5", "The Ops associate must provide 5 why analysis on the defect in DMP SIM."),
            ("Step 6", "In case defect is accepted or confirmed, the quality analyst closes the DMP SIM and opens respective QA rework SIM-Ticket (SIMT) if the parameter failed is a critical one."),
            ("Step 7", "In case defect is appealed, the quality analyst and Ops associate must follow the RISC WW RW DMP SOP to conclude the appeal resolution and final root cause."),
            ("Step 8", "After root cause identification, Q-Ops/AIT PoC elaborates weekly quality report and shares it with Ops WW managers. Initially, the quality report represents a semi-automated QuickSight dashboard, with manual dataset preparation. (automated QuickSight dashboard to be created)"),
            ("Step 9", "Q-Ops/AIT PoC performs monthly or ad-hoc RCA, to identify specific defect trends, based on data provided in the quality report and highlights to Ops the areas of improvement, along with Q-Ops recommendations to mitigate the errors via CAPA SIM (using CAPA document template)."),
            ("Step 10", "Ops PoC must develop a CAPA plan to mitigate the errors, based on the defect trends highlighted and recommendations from Q-Ops, and implements CAPAs post Q-Ops validation through CAPA SIM."),
            ("Step 11", "Q-Ops/AIT SME/PoC and Q-Ops manager review the CAPA plan offered from Ops PoC and validate it or request Ops to rework this in CAPA SIM."),
            ("Step 12", "Q-Ops/AIT PoC monitors sustainability and measure effectiveness of CAPAs post implementation as per timelines agreed, and requests respective measures from Ops PoC in case the plan is unfulfilled or ineffective."),
         ]
        ),
        ("What are the examples for pre-deployment QC actions?",
         [
            ("Step", "RW Pre-Deployment QC Action"),
            ("Step 1", "The Ops PoCs are ensuring that daily population of RW resolved ticket types eligible for pre-deployment QC have raised dedicated QC request tickets in the Q-Ops dedicated SIMT category, type, item (CTI)."),
            ("Step 2", "The Q-Ops/AIT PoC is ensuring daily that RW QC request tickets are flowing in dedicated Anduril SIMT UI – default SIMT template."),
            ("Step 3", "The quality analyst proceeds with QC on the daily sampled tickets within the Anduril SIMT workstream dedicated to RW pre-deployment QC."),
            ("Step 4", "In case of QC parameters failed to pass, quality analyst proceeds with defect notification via RW QC request ticket, marking the parameters failed and estimated RCA in Anduril SIMT custom fields."),
            ("Step 5", "In case a defect is depicted, the quality analyst opens respective QA rework SIMT, if at least one of the critical parameters is failed."),
            ("Step 6", "In case defect is accepted, the Ops associate will rework the class as per requirements set by quality analyst in QA rework ticket. All QA rework tickets will enter the post-deployment QC queue for the respective week."),
            ("Step 7", "If case of doubts regarding the defects highlighted in the QA rework SIMT, the Ops associate can consult the Ops SME to confirm the quality analyst specific rework requirements."),
            ("Step 8", "After root cause identification, Q-Ops/AIT PoC elaborates weekly quality report and shares it with Ops WW managers. Initially, the quality report represents a semi-automated QuickSight dashboard, with manual dataset preparation. (automated QuickSight dashboard to be created)"),
            ("Step 9", "Q-Ops/AIT PoC performs monthly or ad-hoc RCA, to identify specific defect trends, based on data provided in the quality report and highlights to Ops the areas of improvement, along with Q-Ops recommendations to mitigate the errors via CAPA SIM (using CAPA document template)."),
            ("Step 10", "Ops PoC must develop a CAPA plan to mitigate the errors, based on the defect trends highlighted and recommendations from Q-Ops, and implements CAPAs post Q-Ops validation through CAPA SIM."),
            ("Step 11", "Q-Ops/AIT SME/PoC and Q-Ops manager review the CAPA plan offered from Ops PoC and validate it or request Ops to rework this in CAPA SIM."),
            ("Step 12", "Q-Ops/AIT PoC monitors sustainability and measure effectiveness of CAPAs post implementation as per timelines agreed, and requests respective measures from Ops PoC in case the plan is unfulfilled or ineffective."),
         ]
        ),
        ("What are the SLA/TAT for post-deployment?",
         [
            ("Task", "Task Details in Post-deployment", "TAT"),
            ("Export of week-1 population in S3 Buckets", "Every Sunday end of day (EoD)"),
            ("Week-1 QC sample generated in S3 Buckets and Anduril", "Every Sunday EoD"),
            ("QC completion of week-1 in Anduril", "5 business days (BDs) – Friday EoD (all nodes except Amman) and Sunday EoD (Amman)"),
            ("Raise DMP SIMs for parameters failed", "Once the case QC is completed, Friday EoD at latest"),
            ("Error acceptance and 5 why analysis/appeal reason with SME/PE validation", "1 BD – 24 hours (H)"),
            ("Error dispute resolution", "1 BD – 24H for Ops SME/PE"),
            ("Error dispute resolution", "1 BD – 24H for Q-Ops SME/PE"),
            ("Error dispute resolution", "1 BD – 24H for Legal/PT clarification"),
            ("Quality report publication of week-2 in QuickSight", "Every Tuesday EoD (to be confirmed with TSEOA)"),
            ("RCA and CAPA plan request", "The 10th of every month or ad-hoc when defect trends are observed"),
            ("CAPA plan offer", "CAPA plan rework"),
            ("CAPA validation", "2 BDs – 48H"),
            ("CAPA revalidation", "2 BDs – 48H"),
            ("CAPA sustainability", "4 calendar weeks from implementation"),
         ]
        ),
        ("What are the examples for post-deployment?",
         [
            ("Music Player: MP4 player with streaming function. Allows to access Internet for browsing purposes. In-scope - TP", "Laptops: Laptops and computers by default are TP for this rule due the fact they need internet connection for browsing. Allows to access Internet for browsing purpose. In-scope - TP", "Game Console: Game console with Android/wifi connection. Allows to access Internet for browsing purpose. Treated as in scope as it creates an unsupervised browsing opportunity and have an operating system. UI present (User Interface), which allows Parental Control settings to be enabled) - criterion 2 (Android system present). In-scope - TP", "Smartphones: Smartphones are by default TP for this rule due the fact they need internet connection for browsing. Allows to access Internet for browsing purposes. In-scope - TP", "Smart TV: Smart TV/streaming/apps. Allows to access Internet for browsing purposes. In-scope - TP", "Smart Monitor: Smart monitor wirelessly connect/streaming. Allows to access Internet for browsing purposes. In-scope - TP", "Tablet: Tablet with wi-fi connection and internet browsing function. Allows to access Internet for browsing purposes. In-scope - TP", "E-book reader: E-book reader, WIFI sign in the pictures. In-scope - TP", "Smart Watch: Smartwatch with wi-fi connection and NFC function. The connection to the internet and allowing browsing are indirect (criterion 1 fulfilled). Play Store build in. These devices create an unsupervised browsing opportunity. UI present (User Interface), which allows Parental Control settings to be enabled) - criterion 2. In-scope - TP", "GPS devices: GPS with Wifi connection. Allows to access Internet for browsing purposes. In-scope - TP", "Conference Phones: Conference Phone with wi-fi connection. Treated as in scope as it creates an unsupervised browsing opportunity (Android 11.0 as an operating system). In-scope - TP", "Pocket PC: Wireless connection. Allows to access Internet for browsing purposes. In-scope - TP", "Classic MP3: Classic Mp3, without internet connection. Out of scope - FP", "Digital Camera: Photo Camera. Out of scope - FP", "Classic Phone: Classic Phone mobile without wi-fi connection. Out of scope - FP", "Quartz Watch: Quartz Watch. Out of scope - FP", "Fitness Bracelet: Fitness Bracelet with no internet connection feature. Out of scope - FP", "Arcade Game: Arcade Game. Out of scope - FP", "Wired Monitor: Wired Monitor. Out of scope - FP", "Portable TV/Monitor: Portable TV/monitor - just an accessory. Out of scope - FP", "Graphic Tablet: Graphic Tablet with no internet connection. Out of scope - FP", "Toy Version: Toy version. Out of scope - FP", "Analog TV: Analog TV. Out of scope - FP", "Security Camera: Security camera. Out of scope - FP", "Wi-Fi Dongle: Wi-Fi Dongle. Out of scope - FP", "WiFi Router: WiFi Router. Out of scope - FP", "Wi-Fi Extender: Wi-Fi Extender. Out of scope - FP", "Chromecast: Chromecast. Out of scope - FP", "Spare Parts: Spare parts. Out of scope - FP", "GPS Tracker for Pets: GPS tracker for pets. Out of scope - FP"),
         ]
        ),
        ("What are the examples for pre-deployment?",
         [
            ("Classic MP3: Classic Mp3, without internet connection. Out of scope - FP", "Digital Camera: Photo Camera. Out of scope - FP", "Classic Phone: Classic Phone mobile without wi-fi connection. Out of scope - FP", "Quartz Watch: Quartz Watch. Out of scope - FP", "Fitness Bracelet: Fitness Bracelet with no internet connection feature. Out of scope - FP", "Arcade Game: Arcade Game. Out of scope - FP", "Wired Monitor: Wired Monitor. Out of scope - FP", "Portable TV/Monitor: Portable TV/monitor - just an accessory. Out of scope - FP", "Graphic Tablet: Graphic Tablet with no internet connection. Out of scope - FP", "Toy Version: Toy version. Out of scope - FP", "Analog TV: Analog TV. Out of scope - FP", "Security Camera: Security camera. Out of scope - FP", "Wi-Fi Dongle: Wi-Fi Dongle. Out of scope - FP", "WiFi Router: WiFi Router. Out of scope - FP", "Wi-Fi Extender: Wi-Fi Extender. Out of scope - FP", "Chromecast: Chromecast. Out of scope - FP", "Spare Parts: Spare parts. Out of scope - FP", "GPS Tracker for Pets: GPS tracker for pets. Out of scope - FP"),
         ]
        ),
        ("What are the faq for domain3?",
         [
            ("Can I accept the product variation/color variation of the product to which tracking label is attached/affixed?", "Yes, color/pattern/print variation is acceptable between tracking label, only if the two or more are 'substantially equivalent', meaning the physical shape/construction are identical."),
            ("Can I accept the tracking label images present in TR and product tested in TR is color/print/pattern variant?", "Yes, Tracking label images present in TR is acceptable even if the product in Test report is a color/print/pattern variant."),
            ("Hang tag attached to the sleepwear/textile bibs for which tracking information present on information card, can be considered as tracking label on packaging?", "Hang Tag attached to sleepwear or Textile Bibs for which the information card having tracking information can be considered as tracking label for packaging only. It cannot be considered as tracking label for product."),
            ("Do we need tracking information on packaging, If the permanent tracking information on the product is plainly visible through outer or clear packaging?", "No. If all of the required tracking information is visible on the product through outer or clear packaging, there is no need for the tracking information to be on the outer package. In some situations, seller may present only the images of bibs and not clear outer packaging & it is acceptable if the product tracking label is compliant. This is applicable only for Bibs made up of fabric."),
            ("Is there any exception for having tracking label information on Product?", "Yes, as per CPSC 'it may not be practical for permanent distinguishing marks to be printed on small toys and other small products that are manufactured and shipped without individual packaging. In those situations, the package or carton in which the products are shipped to the retailer should be marked', means due to small size of products like 'baby feeding product' tracking label information present on packaging is acceptable for both packaging and product itself."),
            ("What is RN# number and why do we accept the RN# as alternate for manufacturer/distributor/importer name?", "Businesses can use a registered identification number (RN) also called as RN# number. Using the RN database we can able to identify the Manufacturer detail in the RN database. It is not mandatory to SP to include RN# in tracking label, but we can accept as alternate for Tracking label requirement mentioned in section 6.1.")
         ]
        ),
        ("What are the revision history for domain3?",
         [
            ("V00", "25 November 2020", "Created", "saharadb"),
            ("V01", "14 January 2021", "Removed Step 2: Is the Manufacturer or Distributor's location listed in the United States? Reformatted sections", "saharadb"),
            ("V03", "20 January 2021", "Added Product Packaging Label - Printed on Shipping Container example to Appendix B", "saharadb"),
            ("V04", "9 February 2021", "Added additional unacceptable Tracking Label, specifically where Amazon is listed as Importer/Manufacturer/Distributor, etc", "saharadb"),
            ("V05", "18 February 2021", "Changed Registration card review step. Added FAQ on color/product variation in tracking label", "deepaknk"),
            ("V06", "26 February 2021", "Added Section for Hang Tags, Sewn Tags, and Sticker Labels. Sticker label. Paper struck label for sleepwear. Added lot/date code as acceptable for date of manufacturer on Consumer Registration Card. (saharadb)", "deepaknk, saharadb"),
            ("V07", "14 April 2021", "Marked postage paid as a required field for registration cards. Moved Appendix D template example to Section 6.3. Edited Appendix D to include examples of unacceptable registration cards. Updated Review Process", "saharadb"),
            ("V08", "16 April 2021", "Added review step to section 6.1.1. Added examples for paper struck label", "deepaknk"),
            ("V09", "23 April 2021", "FAQ Q1: changed to accept the color/print/pattern variation. Q2, Q3, Q4 & Q5 added to FAQ. Note added in Registration card section for test standard. Changed review step for Section 103.", "deepaknk"),
            ("V10", "7 May 2021", "Accepting Barcode as tracking label guidance added", "deepaknk"),
            ("V11", "18 May 2021", "Added additional note in section 6.3. Added additional unacceptable registration card example in Appendix D", "saharadb"),
            ("V12", "28 May 2021", "Added note in section 6.1.1 to request tracking label images only on product for children Sleepwear PRC", "deepaknk"),
            ("V13", "06 July 2021", "Added alternate for Manufacturer or Private labeler for Section 103 requirement", "deepaknk"),
            ("V14", "20 July 2021", "Added RN# as alternate for manufacturer/importer/distributor name for section 103 requirement. Added FAQ #06", "deepaknk"),
            ("V15", "02 October 2021", "Added adhesive labels as acceptable for permanent labels per packaging CPSC guidance", "saharadb"),
            ("V16", "20th May 2022", "1. Added Paper glued information on registration under 10 Appendix D - Unacceptable Product Registration Cards. 2. Added Note under CPSIA 103 tracking label assessment. To request tracking label images only on product/packaging if Test Report is tested for only packaging/product and no other source of tracking label is available.", "guhimani/sskrl"),
            ("V17", "21 June 2023", "Added Tracking label FAQ", "smthdas"),
            ("V18", "12 December 2023", "Added Tracking Label 'On The Self' Example as acceptable tracking labels", "smthdas")
         ]
        ),
        ("What are the appendix a for domain3?",
         [
            "Baby Changing Products", "Infant Bath Seats", "Bassinets and Cradles", "Infant Bath Tubs", "Bedside Sleepers", "Infant Bouncer Seats", "Booster Seats", "Infant Swings", "Carriages and Strollers", "Infant Walkers", "Children’s Folding Chairs and Stools", "Play Yards", "Cribs (Full-Size)", "Portable Bed Rails", "Cribs (Non Full-Size)", "Portable Hook-On Chairs", "Frame Child Carriers", "Gates and Enclosures", "Soft Infant and Toddler Carriers", "Hand-Held Infant Carriers", "Stationary Activity Centers", "High Chairs", "Toddler Beds"
         ]
        ),
        ("What are the appendix b for domain3?",
         [
            "On the Self Product Examples - We can accept the tracking label considering the product is 'ON THE SHELF' product. i.e the product will be sold directly from the shelves without outer packaging (4 pcs in box and product will be sold separately from display). Like garments sold directly from the shelf and no packaging.",
            "Internal, Sewn Tracking Labels and Hang Tags – Disney Descendants Children’s School Bag Set (Includes: backpack, pencil case, and lunch bag). The first two images are found inside each product and together, include all required information. The last image is of a hang tag with all required information.",
            "Hang Tags – Skip Hop Zoo Backpack. The first two images are of the hang tag, second tag lists all required information. Last image is found inside backpack and includes all required information.",
            "Hang Tags – Bath Toys. The second image shows the reverse side of the hang tags, where all required information is listed.",
            "Hang Tags and Sewn Tags – Stuffed Animal. The third and fourth images show the inside of the hang tag and close up of the sewn tag, where all required information is listed.",
            "Hang Tags – Toy Dinosaur. The second image shows the inside of the hang tag, where most of the required information is listed.",
            "Packaging – Squishy Toys. The packaging contains most of the required information.",
            "Sticker Label – Putty. The image below is of an acceptable sticker tracking label. The sticker represents the product packaging with all regulatory and compliance requirements, including CPSIA tracking label requirements. This sticker’s quality and content suggests it is mass produced and applied to all products during manufacturing. Furthermore, the sticker appears under the product shrink wrap. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Hang Tags, Sewn Tags, and Sticker Labels. First image is of the products as a whole. The second image is of the lunch bag hang tags. Third image is of the sewn labels found inside both lunch bags. The fourth image is a sticker label on the bottom of the water bottle. This sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Sticker Labels. The second and third images show valid sticker labels. The sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Paper struck label for Sleepwear (Sleepwear Tracking Labels should also be on the clothing item itself, see the following example). The below images show the images of the Printed paper tracking label pasted on polybag for sleepwear products. These are accepted.",
            "Sewn in Tag for Sleepwear Products specifically.",
            "Product Packaging Label - Printed on Shipping Container. Tracking labels printed onto a cardboard shipping container are acceptable ONLY if the shipping box is the final product packaging, that will be delivered to the customer. Tracking labels placed on product packaging for FC delivery, wherein the stored products will be received and placed into bins, does not satisfy the tracking label requirement, as the customer will not receive this packaging.",
            "Acceptable Product Packaging Images.",
            "Barcode in Tracking label. Barcode on the product packaging can be acceptable because of first few set of numbers in barcode is referred to manufacturer code/number. This can be accepted only when the barcode is given in below format.",
            "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging.",
            ("Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed.",
            "Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."
         ]
        ),
        ("What are the appendix c for domain3?",
         [
            "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging.",
            "Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed.",
            "Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."
         ]
        ),
        ("What are the appendix d for domain3?",
         [
            "Registration Card is unacceptable because it is not a live image; and does not match the template listed in Section 6.3.",
            "Registration Card is unacceptable because it is not a live image and does not show postage paid.",
            "Registration Card is unacceptable because it does not match the template shown in Section 6.3 and it only shows one side.",
            "Registration Card is unacceptable because it is a print out on standard sized paper, which is unacceptable. This is not post card sized, it only shows one side, and it does not include postage paid.",
            "Registration Card is unacceptable because it is not a live image; and does not match the template listed in Section 6.3.",
            "Registration Card is unacceptable because it is not a live image and does not show postage paid.",
            "Registration Card is unacceptable because it does not match the template shown in Section 6.3 and it only shows one side.",
            "Registration Card is unacceptable because it is a print out on standard sized paper, which is unacceptable. This is not post card sized, it only shows one side, and it does not include postage paid."
         ]
        ),
        ("What are the examples for domain3?",
         [
            ("On the Self Product Examples - We can accept the tracking label considering the product is 'ON THE SHELF' product. i.e the product will be sold directly from the shelves without outer packaging (4 pcs in box and product will be sold separately from display). Like garments sold directly from the shelf and no packaging.",
            "Internal, Sewn Tracking Labels and Hang Tags – Disney Descendants Children’s School Bag Set (Includes: backpack, pencil case, and lunch bag). The first two images are found inside each product and together, include all required information. The last image is of a hang tag with all required information.",
            "Hang Tags – Skip Hop Zoo Backpack. The first two images are of the hang tag, second tag lists all required information. Last image is found inside backpack and includes all required information.",
            "Hang Tags – Bath Toys. The second image shows the reverse side of the hang tags, where all required information is listed.",
            "Hang Tags and Sewn Tags – Stuffed Animal. The third and fourth images show the inside of the hang tag and close up of the sewn tag, where all required information is listed.",
            "Hang Tags – Toy Dinosaur. The second image shows the inside of the hang tag, where most of the required information is listed.",
            "Packaging – Squishy Toys. The packaging contains most of the required information.",
            "Sticker Label – Putty. The image below is of an acceptable sticker tracking label. The sticker represents the product packaging with all regulatory and compliance requirements, including CPSIA tracking label requirements. This sticker’s quality and content suggests it is mass produced and applied to all products during manufacturing. Furthermore, the sticker appears under the product shrink wrap. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Hang Tags, Sewn Tags, and Sticker Labels. First image is of the products as a whole. The second image is of the lunch bag hang tags. Third image is of the sewn labels found inside both lunch bags. The fourth image is a sticker label on the bottom of the water bottle. This sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Sticker Labels. The second and third images show valid sticker labels. The sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Paper struck label for Sleepwear (Sleepwear Tracking Labels should also be on the clothing item itself, see the following example). The below images show the images of the Printed paper tracking label pasted on polybag for sleepwear products. These are accepted.",
            "Sewn in Tag for Sleepwear Products specifically.",
            "Product Packaging Label - Printed on Shipping Container. Tracking labels printed onto a cardboard shipping container are acceptable ONLY if the shipping box is the final product packaging, that will be delivered to the customer. Tracking labels placed on product packaging for FC delivery, wherein the stored products will be received and placed into bins, does not satisfy the tracking label requirement, as the customer will not receive this packaging.",
            "Acceptable Product Packaging Images.",
            "Barcode in Tracking label. Barcode on the product packaging can be acceptable because of first few set of numbers in barcode is referred to manufacturer code/number. This can be accepted only when the barcode is given in below format.",
            "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging.",
            "Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed.",
            "Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."
         ]
        ),
        ("What are the faq for domain3?",
         [
            ("Can I accept the product variation/color variation of the product to which tracking label is attached/affixed?", "Yes, color/pattern/print variation is acceptable between tracking label, only if the two or more are 'substantially equivalent', meaning the physical shape/construction are identical."),
            ("Can I accept the tracking label images present in TR and product tested in TR is color/print/pattern variant?", "Yes, Tracking label images present in TR is acceptable even if the product in Test report is a color/print/pattern variant."),
            ("Hang tag attached to the sleepwear/textile bibs for which tracking information present on information card, can be considered as tracking label on packaging?", "Hang Tag attached to sleepwear or Textile Bibs for which the information card having tracking information can be considered as tracking label for packaging only. It cannot be considered as tracking label for product."),
            ("Do we need tracking information on packaging, If the permanent tracking information on the product is plainly visible through outer or clear packaging?", "No. If all of the required tracking information is visible on the product through outer or clear packaging, there is no need for the tracking information to be on the outer package. In some situations, seller may present only the images of bibs and not clear outer packaging & it is acceptable if the product tracking label is compliant. This is applicable only for Bibs made up of fabric."),
            ("Is there any exception for having tracking label information on Product?", "Yes, as per CPSC 'it may not be practical for permanent distinguishing marks to be printed on small toys and other small products that are manufactured and shipped without individual packaging. In those situations, the package or carton in which the products are shipped to the retailer should be marked', means due to small size of products like 'baby feeding product' tracking label information present on packaging is acceptable for both packaging and product itself."),
            ("What is RN# number and why do we accept the RN# as alternate for manufacturer/distributor/importer name?", "Businesses can use a registered identification number (RN) also called as RN# number. Using the RN database we can able to identify the Manufacturer detail in the RN database. It is not mandatory to SP to include RN# in tracking label, but we can accept as alternate for Tracking label requirement mentioned in section 6.1.")
         ]
        ),
        ("What are the revision history for domain3?",
         [
            ("V00", "25 November 2020", "Created", "saharadb"),
            ("V01", "14 January 2021", "Removed Step 2: Is the Manufacturer or Distributor's location listed in the United States? Reformatted sections", "saharadb"),
            ("V03", "20 January 2021", "Added Product Packaging Label - Printed on Shipping Container example to Appendix B", "saharadb"),
            ("V04", "9 February 2021", "Added additional unacceptable Tracking Label, specifically where Amazon is listed as Importer/Manufacturer/Distributor, etc", "saharadb"),
            ("V05", "18 February 2021", "Changed Registration card review step. Added FAQ on color/product variation in tracking label", "deepaknk"),
            ("V06", "26 February 2021", "Added Section for Hang Tags, Sewn Tags, and Sticker Labels. Sticker label. Paper struck label for sleepwear. Added lot/date code as acceptable for date of manufacturer on Consumer Registration Card. (saharadb)", "deepaknk, saharadb"),
            ("V07", "14 April 2021", "Marked postage paid as a required field for registration cards. Moved Appendix D template example to Section 6.3. Edited Appendix D to include examples of unacceptable registration cards. Updated Review Process", "saharadb"),
            ("V08", "16 April 2021", "Added review step to section 6.1.1. Added examples for paper struck label", "deepaknk"),
            ("V09", "23 April 2021", "FAQ Q1: changed to accept the color/print/pattern variation. Q2, Q3, Q4 & Q5 added to FAQ. Note added in Registration card section for test standard. Changed review step for Section 103.", "deepaknk"),
            ("V10", "7 May 2021", "Accepting Barcode as tracking label guidance added", "deepaknk"),
            ("V11", "18 May 2021", "Added additional note in section 6.3. Added additional unacceptable registration card example in Appendix D", "saharadb"),
            ("V12", "28 May 2021", "Added note in section 6.1.1 to request tracking label images only on product for children Sleepwear PRC", "deepaknk"),
            ("V13", "06 July 2021", "Added alternate for Manufacturer or Private labeler for Section 103 requirement", "deepaknk"),
            ("V14", "20 July 2021", "Added RN# as alternate for manufacturer/importer/distributor name for section 103 requirement. Added FAQ #06", "deepaknk"),
            ("V15", "02 October 2021", "Added adhesive labels as acceptable for permanent labels per packaging CPSC guidance", "saharadb"),
            ("V16", "20th May 2022", "1. Added Paper glued information on registration under 10 Appendix D - Unacceptable Product Registration Cards. 2. Added Note under CPSIA 103 tracking label assessment. To request tracking label images only on product/packaging if Test Report is tested for only packaging/product and no other source of tracking label is available.", "guhimani/sskrl"),
            ("V17", "21 June 2023", "Added Tracking label FAQ", "smthdas"),
            ("V18", "12 December 2023", "Added Tracking Label 'On The Self' Example as acceptable tracking labels", "smthdas")
         ]
        ),
        ("What are the appendix a for domain3?",
         [
            "Baby Changing Products", "Infant Bath Seats", "Bassinets and Cradles", "Infant Bath Tubs", "Bedside Sleepers", "Infant Bouncer Seats", "Booster Seats", "Infant Swings", "Carriages and Strollers", "Infant Walkers", "Children’s Folding Chairs and Stools", "Play Yards", "Cribs (Full-Size)", "Portable Bed Rails", "Cribs (Non Full-Size)", "Portable Hook-On Chairs", "Frame Child Carriers", "Gates and Enclosures", "Soft Infant and Toddler Carriers", "Hand-Held Infant Carriers", "Stationary Activity Centers", "High Chairs", "Toddler Beds"
         ]
        ),
        ("What are the appendix b for domain3?",
         [
            "On the Self Product Examples - We can accept the tracking label considering the product is 'ON THE SHELF' product. i.e the product will be sold directly from the shelves without outer packaging (4 pcs in box and product will be sold separately from display). Like garments sold directly from the shelf and no packaging.",
            "Internal, Sewn Tracking Labels and Hang Tags – Disney Descendants Children’s School Bag Set (Includes: backpack, pencil case, and lunch bag). The first two images are found inside each product and together, include all required information. The last image is of a hang tag with all required information.",
            "Hang Tags – Skip Hop Zoo Backpack. The first two images are of the hang tag, second tag lists all required information. Last image is found inside backpack and includes all required information.",
            "Hang Tags – Bath Toys. The second image shows the reverse side of the hang tags, where all required information is listed.",
            "Hang Tags and Sewn Tags – Stuffed Animal. The third and fourth images show the inside of the hang tag and close up of the sewn tag, where all required information is listed.",
            "Hang Tags – Toy Dinosaur. The second image shows the inside of the hang tag, where most of the required information is listed.",
            "Packaging – Squishy Toys. The packaging contains most of the required information.",
            "Sticker Label – Putty. The image below is of an acceptable sticker tracking label. The sticker represents the product packaging with all regulatory and compliance requirements, including CPSIA tracking label requirements. This sticker’s quality and content suggests it is mass produced and applied to all products during manufacturing. Furthermore, the sticker appears under the product shrink wrap. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Hang Tags, Sewn Tags, and Sticker Labels. First image is of the products as a whole. The second image is of the lunch bag hang tags. Third image is of the sewn labels found inside both lunch bags. The fourth image is a sticker label on the bottom of the water bottle. This sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Sticker Labels. The second and third images show valid sticker labels. The sticker’s quality and content (barcode) suggests it is mass produced and applied to all products during manufacturing. It would not appear the sticker was printed by an individual on their home printer and applied to the product.",
            "Paper struck label for Sleepwear (Sleepwear Tracking Labels should also be on the clothing item itself, see the following example). The below images show the images of the Printed paper tracking label pasted on polybag for sleepwear products. These are accepted.",
            "Sewn in Tag for Sleepwear Products specifically.",
            "Product Packaging Label - Printed on Shipping Container. Tracking labels printed onto a cardboard shipping container are acceptable ONLY if the shipping box is the final product packaging, that will be delivered to the customer. Tracking labels placed on product packaging for FC delivery, wherein the stored products will be received and placed into bins, does not satisfy the tracking label requirement, as the customer will not receive this packaging.",
            "Acceptable Product Packaging Images.",
            "Barcode in Tracking label. Barcode on the product packaging can be acceptable because of first few set of numbers in barcode is referred to manufacturer code/number. This can be accepted only when the barcode is given in below format.",
            "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging.",
            "Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed.",
            "Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."
         ]
        ),
        ("What are the appendix c for domain3?",
         [
            "Taped Labels – Non-children’s product, but example is still valid. All required information is only present on a loose piece of paper taped onto the packaging.",
            "Taped Labels – Non-children’s product, but example is still valid. The required company and product information is only present on paper that is easily removed.",
            "Sticker Labels – Children’s RC Car. The required company and product information is a sticker that resembles a taped label. This label is unacceptable because it is an example of a selling partner attempting to meet our requirements, but it is unreasonable to think the seller has placed this label on all of their stock."
         ]
        ),
        ("What are the appendix d for domain3?",
         [
            "Registration Card is unacceptable because it is not a live image; and does not match the template listed in Section 6.3.",
            "Registration Card is unacceptable because it is not a live image and does not show postage paid.",
            "Registration Card is unacceptable because it does not match the template shown in Section 6.3 and it only shows one side.",
            "Registration Card is unacceptable because it is a print out on standard sized paper, which is unacceptable. This is not post card sized, it only shows one side, and it does not include postage paid.",
            "Registration Card is unacceptable because it is not a live image; and does not match the template listed in Section 6.3.",
            "Registration Card is unacceptable because it is not a live image and does not show postage paid.",
            "Registration Card is unacceptable because it does not match the template shown in Section 6.3 and it only shows one side.",
            "Registration Card is unacceptable because it is a print out on standard sized paper, which is unacceptable. This is not post card sized, it only shows one side, and it does not include postage paid."
         ]
        ),
    ]
}

# Define data_pool with sample data
data_pool = {
    domain1: {
        "Manufacturer": ["Manufacturer A", "Manufacturer B", "Manufacturer C"],
        "Product": ["Product X", "Product Y", "Product Z"],
        "Location": ["Location 1", "Location 2", "Location 3"],
        "Date": ["Date 1", "Date 2", "Date 3"],
        "BatchNumber": ["Batch 1", "Batch 2", "Batch 3"],
        "ManufacturingProcess": ["Process A", "Process B", "Process C"],
        "CompanyWebsite": ["Website A", "Website B", "Website C"],
        "BrandName": ["Brand A", "Brand B", "Brand C"],
        "RNNumber": ["RN123", "RN456", "RN789"],
        "DistributorCode": ["DCode1", "DCode2", "DCode3"],
        "ManufacturerCode": ["MCode1", "MCode2", "MCode3"],
        "RunNumber": ["Run1", "Run2", "Run3"],
        "ProductInformation": ["Info A", "Info B", "Info C"],
        "TrackingLabel": ["Label A", "Label B", "Label C"],
        "RegistrationCard": ["Card A", "Card B", "Card C"],
        "ASIN": ["ASIN1", "ASIN2", "ASIN3"],
        "SP": ["SP1", "SP2", "SP3"],
        "PrincipalComponent": ["Component A", "Component B", "Component C"],
        "ProductPackaging": ["Packaging A", "Packaging B", "Packaging C"],
        "Section104Product": ["Product 104A", "Product 104B", "Product 104C"],
        "OuterPackaging": ["Packaging Outer A", "Packaging Outer B", "Packaging Outer C"],
        "ManufacturerLocation": ["Location A", "Location B", "Location C"],
        "ProductRegistrationCard": ["Card 104A", "Card 104B", "Card 104C"],
        "SellingPartner": ["Partner A", "Partner B", "Partner C"],
        "LiveProductRegistrationCard": ["Live Card A", "Live Card B", "Live Card C"],
        "InformationCard": ["Info Card A", "Info Card B", "Info Card C"],
        "HangTag": ["Hang Tag A", "Hang Tag B", "Hang Tag C"],
        "SewnTag": ["Sewn Tag A", "Sewn Tag B", "Sewn Tag C"],
        "StickerLabel": ["Sticker A", "Sticker B", "Sticker C"],
        "PaperLabel": ["Paper Label A", "Paper Label B", "Paper Label C"],
        "Barcode": ["Barcode A", "Barcode B", "Barcode C"],
        "TapedLabel": ["Taped Label A", "Taped Label B", "Taped Label C"],
        "UnacceptableTrackingLabel": ["Unacceptable Label A", "Unacceptable Label B", "Unacceptable Label C"],
        "UnacceptableProductRegistrationCard": ["Unacceptable Card A", "Unacceptable Card B", "Unacceptable Card C"],
    },
    domain2: {
        "TerminalEquipment": ["Equipment A", "Equipment B", "Equipment C"],
        "Browsing": ["Browsing A", "Browsing B", "Browsing C"],
        "InScopeDevices": ["Device A", "Device B", "Device C"],
        "OutOfScopeDevices": ["Device X", "Device Y", "Device Z"],
        "BorderlineProducts": ["Product A", "Product B", "Product C"],
        "SmartWatches": ["SmartWatch A", "SmartWatch B", "SmartWatch C"],
        "GPSDevices": ["GPS A", "GPS B", "GPS C"],
        "ProductAssuranceTeam": ["Team A", "Team B", "Team C"],
        "TruePositiveDevices": ["TP Device A", "TP Device B", "TP Device C"],
        "FalsePositiveDevices": ["FP Device A", "FP Device B", "FP Device C"],
        "RadioEquipment": ["Radio A", "Radio B", "Radio C"],
        "OverestrictiveApproach": ["Approach A", "Approach B", "Approach C"],
    },
    domain3: {
        "RuleWriter": ["Writer A", "Writer B", "Writer C"],
        "SampleReviewer": ["Reviewer A", "Reviewer B", "Reviewer C"],
        "OpsSME": ["SME A", "SME B", "SME C"],
        "OpsManager": ["Manager A", "Manager B", "Manager C"],
        "ProgramTeam": ["Team A", "Team B", "Team C"],
        "QualityAnalyst": ["Analyst A", "Analyst B", "Analyst C"],
        "QualitySpecialist": ["Specialist A", "Specialist B", "Specialist C"],
        "QualityManager": ["QManager A", "QManager B", "QManager C"],
        "TSEOA": ["TSEOA A", "TSEOA B", "TSEOA C"],
        "QOpsPoC": ["QOpsPoC A", "QOpsPoC B", "QOpsPoC C"],
        "OpsPoC": ["OpsPoC A", "OpsPoC B", "OpsPoC C"],
        "QOpsManager": ["QManager A", "QManager B", "QManager C"],
        "PT": ["PT A", "PT B", "PT C"],
        "OpsLeadership": ["Leadership A", "Leadership B", "Leadership C"],
        "RISCWWRWDocument": ["Document A", "Document B", "Document C"],
        "RISCWWRWDocumentVersion": ["Version A", "Version B", "Version C"],
        "RISCWWRWDocumentAuthor": ["Author A", "Author B", "Author C"],
        "RISCWWRWDocumentApprover": ["Approver A", "Approver B", "Approver C"],
        "RISCWWRWDocumentReviewer": ["Reviewer A", "Reviewer B", "Reviewer C"],
        "RISCWWRWDocumentDate": ["Date A", "Date B", "Date C"],
        "RISCWWRWDocumentChange": ["Change A", "Change B", "Change C"],
        "RISCWWRWDocumentChangeAuthor": ["Change Author A", "Change Author B", "Change Author C"],
        "RISCWWRWDocumentChangeDate": ["Change Date A", "Change Date B", "Change Date C"],
        "RISCWWRWDocumentChangeReviewer": ["Change Reviewer A", "Change Reviewer B", "Change Reviewer C"],
        "RISCWWRWDocumentChangeApprover": ["Change Approver A", "Change Approver B", "Change Approver C"],
        "RISCWWRWDocumentChangeVersion": ["Change Version A", "Change Version B", "Change Version C"],
        "RISCWWRWDocumentChangeDescription": ["Change Description A", "Change Description B", "Change Description C"],
        "RISCWWRWDocumentChangeReason": ["Change Reason A", "Change Reason B", "Change Reason C"],
        "RISCWWRWDocumentChangeImpact": ["Change Impact A", "Change Impact B", "Change Impact C"],
        "RISCWWRWDocumentChangeRisk": ["Change Risk A", "Change Risk B", "Change Risk C"],
        "RISCWWRWDocumentChangeMitigation": ["Change Mitigation A", "Change Mitigation B", "Change Mitigation C"],
        "RISCWWRWDocumentChangeValidation": ["Change Validation A", "Change Validation B", "Change Validation C"],
        "RISCWWRWDocumentChangeImplementation": ["Change Implementation A", "Change Implementation B", "Change Implementation C"],
        "RISCWWRWDocumentChangeEffectiveness": ["Change Effectiveness A", "Change Effectiveness B", "Change Effectiveness C"],
        "RISCWWRWDocumentChangeSustainability": ["Change Sustainability A", "Change Sustainability B", "Change Sustainability C"],
        "RISCWWRWDocumentChangeReview": ["Change Review A", "Change Review B", "Change Review C"],
        "RISCWWRWDocumentChangeApproval": ["Change Approval A", "Change Approval B", "Change Approval C"],
        "RISCWWRWDocumentChangeReviewDate": ["Change Review Date A", "Change Review Date B", "Change Review Date C"],
        "RISCWWRWDocumentChangeApprovalDate": ["Change Approval Date A", "Change Approval Date B", "Change Approval Date C"],
        "RISCWWRWDocumentChangeReviewerName": ["Change Reviewer Name A", "Change Reviewer Name B", "Change Reviewer Name C"],
        "RISCWWRWDocumentChangeApproverName": ["Change Approver Name A", "Change Approver Name B", "Change Approver Name C"],
        "RISCWWRWDocumentChangeReviewerComments": ["Change Reviewer Comments A", "Change Reviewer Comments B", "Change Reviewer Comments C"],
        "RISCWWRWDocumentChangeApproverComments": ["Change Approver Comments A", "Change Approver Comments B", "Change Approver Comments C"],
        "RISCWWRWDocumentChangeReviewerStatus": ["Change Reviewer Status A", "Change Reviewer Status B", "Change Reviewer Status C"],
        "RISCWWRWDocumentChangeApproverStatus": ["Change Approver Status A", "Change Approver Status B", "Change Approver Status C"],
        "RISCWWRWDocumentChangeReviewerDecision": ["Change Reviewer Decision A", "Change Reviewer Decision B", "Change Reviewer Decision C"],
        "RISCWWRWDocumentChangeApproverDecision": ["Change Approver Decision A", "Change Approver Decision B", "Change Approver Decision C"],
        "RISCWWRWDocumentChangeReviewerRecommendation": ["Change Reviewer Recommendation A", "Change Reviewer Recommendation B", "Change Reviewer Recommendation C"],
        "RISCWWRWDocumentChangeApproverRecommendation": ["Change Approver Recommendation A", "Change Approver Recommendation B", "Change Approver Recommendation C"],
        "RISCWWRWDocumentChangeReviewerAction": ["Change Reviewer Action A", "Change Reviewer Action B", "Change Reviewer Action C"],
        "RISCWWRWDocumentChangeApproverAction": ["Change Approver Action A", "Change Approver Action B", "Change Approver Action C"],
        "RISCWWRWDocumentChangeReviewerNextSteps": ["Change Reviewer Next Steps A", "Change Reviewer Next Steps B", "Change Reviewer Next Steps C"],
        "RISCWWRWDocumentChangeApproverNextSteps": ["Change Approver Next Steps A", "Change Approver Next Steps B", "Change Approver Next Steps C"],
        "RISCWWRWDocumentChangeReviewerFollowUp": ["Change Reviewer Follow Up A", "Change Reviewer Follow Up B", "Change Reviewer Follow Up C"],
        "RISCWWRWDocumentChangeApproverFollowUp": ["Change Approver Follow Up A", "Change Approver Follow Up B", "Change Approver Follow Up C"],
        "RISCWWRWDocumentChangeReviewerEscalation": ["Change Reviewer Escalation A", "Change Reviewer Escalation B", "Change Reviewer Escalation C"],
        "RISCWWRWDocumentChangeApproverEscalation": ["Change Approver Escalation A", "Change Approver Escalation B", "Change Approver Escalation C"],
        "RISCWWRWDocumentChangeReviewerEscalationReason": ["Change Reviewer Escalation Reason A", "Change Reviewer Escalation Reason B", "Change Reviewer Escalation Reason C"],
        "RISCWWRWDocumentChangeApproverEscalationReason": ["Change Approver Escalation Reason A", "Change Approver Escalation Reason B", "Change Approver Escalation Reason C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolution": ["Change Reviewer Escalation Resolution A", "Change Reviewer Escalation Resolution B", "Change Reviewer Escalation Resolution C"],
        "RISCWWRWDocumentChangeApproverEscalationResolution": ["Change Approver Escalation Resolution A", "Change Approver Escalation Resolution B", "Change Approver Escalation Resolution C"],
        "RISCWWRWDocumentChangeReviewerEscalationStatus": ["Change Reviewer Escalation Status A", "Change Reviewer Escalation Status B", "Change Reviewer Escalation Status C"],
        "RISCWWRWDocumentChangeApproverEscalationStatus": ["Change Approver Escalation Status A", "Change Approver Escalation Status B", "Change Approver Escalation Status C"],
        "RISCWWRWDocumentChangeReviewerEscalationDate": ["Change Reviewer Escalation Date A", "Change Reviewer Escalation Date B", "Change Reviewer Escalation Date C"],
        "RISCWWRWDocumentChangeApproverEscalationDate": ["Change Approver Escalation Date A", "Change Approver Escalation Date B", "Change Approver Escalation Date C"],
        "RISCWWRWDocumentChangeReviewerEscalationComments": ["Change Reviewer Escalation Comments A", "Change Reviewer Escalation Comments B", "Change Reviewer Escalation Comments C"],
        "RISCWWRWDocumentChangeApproverEscalationComments": ["Change Approver Escalation Comments A", "Change Approver Escalation Comments B", "Change Approver Escalation Comments C"],
        "RISCWWRWDocumentChangeReviewerEscalationAction": ["Change Reviewer Escalation Action A", "Change Reviewer Escalation Action B", "Change Reviewer Escalation Action C"],
        "RISCWWRWDocumentChangeApproverEscalationAction": ["Change Approver Escalation Action A", "Change Approver Escalation Action B", "Change Approver Escalation Action C"],
        "RISCWWRWDocumentChangeReviewerEscalationNextSteps": ["Change Reviewer Escalation Next Steps A", "Change Reviewer Escalation Next Steps B", "Change Reviewer Escalation Next Steps C"],
        "RISCWWRWDocumentChangeApproverEscalationNextSteps": ["Change Approver Escalation Next Steps A", "Change Approver Escalation Next Steps B", "Change Approver Escalation Next Steps C"],
        "RISCWWRWDocumentChangeReviewerEscalationFollowUp": ["Change Reviewer Escalation Follow Up A", "Change Reviewer Escalation Follow Up B", "Change Reviewer Escalation Follow Up C"],
        "RISCWWRWDocumentChangeApproverEscalationFollowUp": ["Change Approver Escalation Follow Up A", "Change Approver Escalation Follow Up B", "Change Approver Escalation Follow Up C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolutionDate": ["Change Reviewer Escalation Resolution Date A", "Change Reviewer Escalation Resolution Date B", "Change Reviewer Escalation Resolution Date C"],
        "RISCWWRWDocumentChangeApproverEscalationResolutionDate": ["Change Approver Escalation Resolution Date A", "Change Approver Escalation Resolution Date B", "Change Approver Escalation Resolution Date C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolutionComments": ["Change Reviewer Escalation Resolution Comments A", "Change Reviewer Escalation Resolution Comments B", "Change Reviewer Escalation Resolution Comments C"],
        "RISCWWRWDocumentChangeApproverEscalationResolutionComments": ["Change Approver Escalation Resolution Comments A", "Change Approver Escalation Resolution Comments B", "Change Approver Escalation Resolution Comments C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolutionAction": ["Change Reviewer Escalation Resolution Action A", "Change Reviewer Escalation Resolution Action B", "Change Reviewer Escalation Resolution Action C"],
        "RISCWWRWDocumentChangeApproverEscalationResolutionAction": ["Change Approver Escalation Resolution Action A", "Change Approver Escalation Resolution Action B", "Change Approver Escalation Resolution Action C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolutionNextSteps": ["Change Reviewer Escalation Resolution Next Steps A", "Change Reviewer Escalation Resolution Next Steps B", "Change Reviewer Escalation Resolution Next Steps C"],
        "RISCWWRWDocumentChangeApproverEscalationResolutionNextSteps": ["Change Approver Escalation Resolution Next Steps A", "Change Approver Escalation Resolution Next Steps B", "Change Approver Escalation Resolution Next Steps C"],
        "RISCWWRWDocumentChangeReviewerEscalationResolutionFollowUp": ["Change Reviewer Escalation Resolution Follow Up A", "Change Reviewer Escalation Resolution Follow Up B", "Change Reviewer Escalation Resolution Follow Up C"],
        "RISCWWRWDocumentChangeApproverEscalationResolutionFollowUp": ["Change Approver Escalation Resolution Follow Up A", "Change Approver Escalation Resolution Follow Up B", "Change Approver Escalation Resolution Follow Up C"],
    ]
    }
}

# Function to generate unique combinations with a time limit
def generate_combinations(template, placeholders, domain_name, time_limit=30):
    """
    Generate unique combinations from a template and placeholders within a given time limit.
    """
    print(f"Placeholders for domain {domain_name}: {placeholders}")

    # Ensure placeholders is a dictionary
    if not isinstance(placeholders, dict):
        print(f"Error: Expected a dictionary for placeholders, but got {type(placeholders)}. Skipping domain: {domain_name}")
        return []

    keys = list(placeholders.keys())
    combinations = set()  # Use a set to ensure uniqueness
    start_time = time.time()  # Record the start time
    progress_interval = 100  # Print progress every 100 pairs generated
    max_attempts = 10000  # Limit attempts to avoid infinite loops or long delays
    attempts = 0  # Counter for attempts to ensure we don't exceed max attempts

    while True:
        # Check if time limit is exceeded
        elapsed_time = time.time() - start_time
        if elapsed_time > time_limit:
            print(f"Time limit exceeded for domain: {domain_name}. Skipping to next domain.")
            break  # Exit the loop if time limit is exceeded

        # Break if max attempts reached to prevent infinite loop
        if attempts >= max_attempts:
            print(f"Max attempts reached for domain: {domain_name}. Skipping to next domain.")
            break

        # Try generating values from placeholders
        try:
            values = {key: random.choice(placeholders[key]) if placeholders[key] else None for key in keys}
            # Skip if any value is None (which means the list was empty)
            if any(value is None for value in values.values()):
                continue

            question = template[0].format(**values)
            answer = template[1].format(**values)
            # Add the pair only if it's unique
            combinations.add((question, answer))

            # Print progress every progress_interval pairs
            if len(combinations) % progress_interval == 0:
                print(f"Domain: {domain_name} - Generated {len(combinations)} pairs...", flush=True)

        except KeyError as e:
            print(f"KeyError in domain {domain_name}: {e} - Skipping invalid combination.")
            continue  # Skip invalid combinations if a KeyError occurs

        attempts += 1  # Increment attempt counter

    return list(combinations)  # Return the list of unique combinations

# Generate Q&A pairs for all domains
qa_pairs = []
for domain, templates in qa_template.items():
    print(f"Generating pairs for domain: {domain}")
    placeholders = data_pool.get(domain, {})

    # Print to debug placeholders
    print(f"Placeholders for domain {domain}: {placeholders}")

    if not placeholders:
        print(f"Warning: No placeholders found for domain: {domain}. Skipping this domain.")
        continue  # Skip the domain if no placeholders are available

    domain_pairs = []  # Collect pairs for the current domain
    for template in templates:
        generated_pairs = generate_combinations(template, placeholders, domain)
        domain_pairs.extend(generated_pairs)

    if domain_pairs:
        qa_pairs.extend(domain_pairs)
    else:
        print(f"Skipping domain: {domain} due to insufficient valid templates or placeholders.")

# Ensure we have exactly 1,000 unique Q&A pairs
while len(qa_pairs) < 1000:
    for domain, templates in qa_template.items():
        placeholders = data_pool.get(domain, {})
        if not placeholders:
            continue
        for template in templates:
            generated_pairs = generate_combinations(template, placeholders, domain)
            qa_pairs.extend(generated_pairs)
            if len(qa_pairs) >= 1000:
                break
        if len(qa_pairs) >= 1000:
            break

# Trim to exactly 1,000 pairs if more than 1,000 were generated
qa_pairs = qa_pairs[:1000]

# Save to CSV
csv_file_path = "learned_responses.csv"
file_exists = os.path.isfile(csv_file_path)

with open(csv_file_path, mode="a", newline='', encoding="utf-8") as file:
    writer = csv.writer(file)
    if not file_exists:
        writer.writerow(["Question", "Answer"])  # Write header if file is new
    writer.writerows(qa_pairs)

print(f"CSV file saved as {csv_file_path} with {len(qa_pairs)} Q&A pairs.")