# -*- coding: utf-8 -*-
import io,sys,ssl,urllib.request,re
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
url="https://uwaterloo.ca/future-graduate-students/programs/by-faculty/engineering/systems-design-engineering-master-engineering-meng"
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0"})
html=urllib.request.urlopen(req,timeout=25,context=ctx).read().decode("utf-8","ignore")
txt=re.sub(r"<script.*?</script>","",html,flags=re.S); txt=re.sub(r"<style.*?</style>","",txt,flags=re.S)
txt=re.sub(r"<[^>]+>"," ",txt); txt=re.sub(r"\s+"," ",txt).strip()
for kw in ["supervisor","self-funded","highlights","Funding","research-based","Course-based"]:
    for m in re.finditer(re.escape(kw),txt):
        i=m.start(); print("["+kw+"]",txt[max(0,i-70):i+170]); break
i=txt.find("Program highlights")
print("\n=== highlights ==="); print(txt[i:i+500] if i>=0 else "NA")
