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

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

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

g = A("g")
c = B("c")
j = C("j")
b = B("b")
h = A("h")
e = C("e")
a = C("a")
f = C("f")

g.v = h
g.z = h
g.u = c
c.x = j
c.t = g
c.q = f
j.p = b
j.x = h
j.w = c
b.x = e
b.t = h
b.q = j
h.v = g
h.z = g
h.u = b
e.p = b
e.w = b
e.x = g
a.p = b
a.x = g
a.w = c
f.p = b
f.x = h
f.w = c
assert g.u.q.w.t.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: B = None
        self.z: A = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
j = C("j")
b = B("b")
h = A("h")
e = C("e")
a = C("a")
f = C("f")

g.v = h
g.z = h
g.u = c
c.x = j
c.t = g
c.q = f
j.p = b
j.x = h
j.w = c
b.x = e
b.t = h
b.q = j
h.v = g
h.z = g
h.u = b
e.p = b
e.w = b
e.x = g
a.p = b
a.x = g
a.w = c
f.p = b
f.x = h
f.w = c
assert g.u.q.w.t.u.q.txt == "f"