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

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

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

k = A("k")
h = B("h")
g = C("g")
f = A("f")
d = B("d")

k.v = h
k.u = d
k.w = d
h.p = g
h.u = g
h.x = d
g.u = k
g.w = k
f.v = d
f.u = d
f.w = d
d.p = g
d.u = g
d.x = h
assert d.u.w.v.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
g = C("g")
f = A("f")
d = B("d")

k.v = h
k.u = d
k.w = d
h.p = g
h.u = g
h.x = d
g.u = k
g.w = k
f.v = d
f.u = d
f.w = d
d.p = g
d.u = g
d.x = h
assert d.u.w.v.u.w.txt == "k"