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

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

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

h = A("h")
b = B("b")
i = C("i")
j = B("j")
f = A("f")

h.q = f
h.t = f
h.z = b
b.w = j
i.v = f
i.s = h
j.w = b
f.q = h
f.t = h
f.z = b
assert f.q.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
i = C("i")
j = B("j")
f = A("f")

h.q = f
h.t = f
h.z = b
b.w = j
i.v = f
i.s = h
j.w = b
f.q = h
f.t = h
f.z = b
assert f.q.z.w.txt == "j"