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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: A = None
        self.u: D = None
        self.v: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: A = None
        self.u: D = None
        self.v: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

k.v = d
h.w = k
n.t = d
n.u = d
n.p = f
n.v = g
d.y = n
g.t = d
g.u = d
g.p = f
g.v = n
f.v = d
assert k.v.y.t.y.t.y.txt == "n"