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

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

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

n = A("n")
c = B("c")
g = C("g")
f = A("f")
a = B("a")
k = C("k")

n.t = f
n.q = f
c.z = g
c.r = g
c.q = g
g.w = k
g.x = k
g.v = f
f.t = n
f.q = n
a.z = g
a.q = g
a.r = k
k.w = g
k.x = g
k.v = n
assert g.x.v.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
g = C("g")
f = A("f")
a = B("a")
k = C("k")

n.t = f
n.q = f
c.z = g
c.r = g
c.q = g
g.w = k
g.x = k
g.v = f
f.t = n
f.q = n
a.z = g
a.q = g
a.r = k
k.w = g
k.x = g
k.v = n
assert g.x.v.t.q.txt == "n"