class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

j = A("j")
k = B("k")
a = C("a")
e = C("e")
c = B("c")
l = A("l")

j.w = l
j.q = l
j.p = a
k.p = a
a.y = e
e.y = a
c.p = a
l.w = j
l.q = j
l.p = a
assert j.p.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

j = A("j")
k = B("k")
a = C("a")
e = C("e")
c = B("c")
l = A("l")

j.w = l
j.q = l
j.p = a
k.p = a
a.y = e
e.y = a
c.p = a
l.w = j
l.q = j
l.p = a
assert j.p.y.y.txt == "a"