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

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

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

g = A("g")
h = B("h")
a = C("a")
f = C("f")

g.v = h
g.y = a
h.s = g
h.r = g
h.q = a
a.u = h
a.z = g
f.u = h
f.z = g
assert f.z.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
a = C("a")
f = C("f")

g.v = h
g.y = a
h.s = g
h.r = g
h.q = a
a.u = h
a.z = g
f.u = h
f.z = g
assert f.z.y.u.txt == "h"