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

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

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

g = A("g")
c = B("c")
i = C("i")

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

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

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

g = A("g")
c = B("c")
i = C("i")

g.q = c
g.v = c
c.v = g
c.s = g
i.r = c
i.w = c
assert g.v.v.q.txt == "c"