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

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

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

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

l.v = h
l.w = h
l.z = f
h.u = f
h.v = f
h.q = a
a.r = h
a.t = h
a.q = h
f.v = h
f.w = h
f.z = l
assert f.v.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: A = None
        self.w: B = None
        self.txt = txt

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

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

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

l.v = h
l.w = h
l.z = f
h.u = f
h.v = f
h.q = a
a.r = h
a.t = h
a.q = h
f.v = h
f.w = h
f.z = l
assert f.v.v.w.txt == "h"