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

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

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

g = A("g")
k = B("k")
j = C("j")
c = A("c")
i = B("i")
a = A("a")
m = C("m")

g.q = a
g.v = c
g.p = m
k.x = c
k.w = j
j.s = m
j.w = g
j.u = k
c.q = g
c.v = a
c.p = m
i.x = g
i.w = m
a.q = c
a.v = c
a.p = j
m.s = j
m.w = g
m.u = k
assert m.w.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
j = C("j")
c = A("c")
i = B("i")
a = A("a")
m = C("m")

g.q = a
g.v = c
g.p = m
k.x = c
k.w = j
j.s = m
j.w = g
j.u = k
c.q = g
c.v = a
c.p = m
i.x = g
i.w = m
a.q = c
a.v = c
a.p = j
m.s = j
m.w = g
m.u = k
assert m.w.p.u.txt == "k"