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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: D = None
        self.y: A = None
        self.t: D = None
        self.txt = txt

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

n = A("n")
m = B("m")
f = C("f")
k = D("k")
c = B("c")

n.v = m
n.t = k
m.u = n
m.y = k
f.s = m
f.w = k
f.t = k
f.y = n
k.o = m
c.u = n
c.y = k
assert n.t.o.u.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: D = None
        self.y: A = None
        self.t: D = None
        self.txt = txt

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

n = A("n")
m = B("m")
f = C("f")
k = D("k")
c = B("c")

n.v = m
n.t = k
m.u = n
m.y = k
f.s = m
f.w = k
f.t = k
f.y = n
k.o = m
c.u = n
c.y = k
assert n.t.o.u.t.o.txt == "m"