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

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

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

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

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

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

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

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

m.q = k
m.z = i
m.o = c
a.x = c
a.v = m
a.w = n
c.t = g
b.x = c
b.v = m
b.w = g
i.q = b
i.z = n
i.o = c
f.x = c
f.v = n
f.w = n
g.q = k
g.z = m
g.o = c
n.q = b
n.z = m
n.o = c
k.x = c
k.v = i
k.w = i
assert i.o.t.q.x.t.txt == "g"