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

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

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

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

c.v = i
c.w = h
a.q = m
a.v = g
b.t = c
b.p = a
g.q = m
g.v = a
m.t = j
m.p = a
j.v = i
j.w = b
h.t = i
h.p = g
i.v = c
i.w = m
assert c.v.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: C = None
        self.txt = txt

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

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

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

c.v = i
c.w = h
a.q = m
a.v = g
b.t = c
b.p = a
g.q = m
g.v = a
m.t = j
m.p = a
j.v = i
j.w = b
h.t = i
h.p = g
i.v = c
i.w = m
assert c.v.w.t.w.txt == "b"