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

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

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

j = A("j")
a = B("a")
h = C("h")
k = B("k")
n = A("n")

j.v = a
j.w = h
a.u = h
a.s = h
h.x = j
h.p = j
k.u = h
k.s = h
n.v = a
n.w = h
assert n.w.x.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
h = C("h")
k = B("k")
n = A("n")

j.v = a
j.w = h
a.u = h
a.s = h
h.x = j
h.p = j
k.u = h
k.s = h
n.v = a
n.w = h
assert n.w.x.w.p.w.txt == "h"