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

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

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

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

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

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

c.t = i
c.q = n
n.v = g
i.t = g
i.q = n
g.t = i
g.q = n
assert i.t.q.v.txt == "g"