class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
m = B("m")
i = C("i")
b = A("b")
c = C("c")
g = B("g")

e.y = b
e.p = g
e.r = m
m.w = b
m.q = i
i.s = g
i.z = b
b.y = e
b.p = m
b.r = m
c.s = m
c.z = b
g.w = e
g.q = i
assert i.s.q.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
m = B("m")
i = C("i")
b = A("b")
c = C("c")
g = B("g")

e.y = b
e.p = g
e.r = m
m.w = b
m.q = i
i.s = g
i.z = b
b.y = e
b.p = m
b.r = m
c.s = m
c.z = b
g.w = e
g.q = i
assert i.s.q.z.y.txt == "e"