class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
g = C("g")
l = C("l")
b = B("b")

e.z = b
h.p = l
h.q = l
h.s = e
g.y = l
g.z = l
l.y = g
l.z = g
b.p = g
b.q = l
b.s = e
assert e.z.q.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
g = C("g")
l = C("l")
b = B("b")

e.z = b
h.p = l
h.q = l
h.s = e
g.y = l
g.z = l
l.y = g
l.z = g
b.p = g
b.q = l
b.s = e
assert e.z.q.y.y.txt == "l"