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

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

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

e = A("e")
g = B("g")
l = C("l")
c = B("c")

e.v = l
e.q = l
e.y = c
g.s = c
g.p = c
g.w = e
l.r = g
c.s = g
c.p = g
c.w = e
assert g.p.w.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
l = C("l")
c = B("c")

e.v = l
e.q = l
e.y = c
g.s = c
g.p = c
g.w = e
l.r = g
c.s = g
c.p = g
c.w = e
assert g.p.w.y.s.txt == "g"